# getUnixNowUnit

Industry: Core

## Signature

```ts
getUnixNowUnit(unit: UnixNowUnit | PluralUnit<DateTimeUnit>): string
```

Return the requested unit value from the current Unix timestamp in UTC.

- Valid units: "year", "month", "week", "day", "dayOfWeek", "hour", "minute", "second", "millisecond", "microsecond", "nanosecond". Temporal units may also be plural ("hours").
- `microsecond` and `nanosecond` are Temporal's 0–999 fields, zero-padded to 3 digits.
- Uses Temporal.Now.instant() converted to UTC zoned date time.
- Returns "" on invalid unit or failure.
- The `"year"` unit is written as Temporal writes a year: four digits (`"2024"`, `"0005"`), or a sign and six digits outside 0000–9999 (`"+010000"`, `"-000005"`).

## Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| `unit` | `UnixNowUnit` \| `PluralUnit<DateTimeUnit>` | unit to extract from current unix timestamp |

## Returns

string representation of the requested unit or "" on invalid

## Types

### UnixNowUnit

Units extractable from the current Unix timestamp in UTC via `getUnixNowUnit`. Defined as `DateTimeUnit | "dayOfWeek"`.

```ts
import type { UnixNowUnit } from "@northguild/gmt";
```

```ts
DateTimeUnit | "dayOfWeek"
```

## Examples

```ts
import { getUnixNowUnit } from "@northguild/gmt/unix/get";

getUnixNowUnit("year") // "2024"
```

## Source

[unix/get/getUnixNowUnit.ts](https://github.com/northguild/gmt/blob/main/packages/gmt/src/unix/get/getUnixNowUnit.ts)
