# getUtcNowUnit

Industry: Core

## Signature

```ts
getUtcNowUnit(unit: UtcNowUnit): string
```

Return the requested unit value from the current UTC instant.

- Valid units: "year", "month", "week", "day", "dayOfWeek", "hour", "minute", "second", "millisecond", "microsecond", "nanosecond".
- Uses Temporal.Now.instant() converted to UTC.
- `unit` accepts the singular or plural name of a Temporal unit (`"hour"` or `"hours"`), as Temporal does; `"dayOfWeek"` has no plural.
- 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` | `UtcNowUnit` | unit to extract from current utc instant |

## Returns

string representation of the requested unit or "" on invalid

## Types

### UtcNowUnit

Units extractable from the current UTC instant via `getUtcNowUnit`. Defined as `DateTimeUnit | "dayOfWeek"`.

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

```ts
SmallestUnit<DateTimeUnit> | "dayOfWeek"
```

## Examples

```ts
import { getUtcNowUnit } from "@northguild/gmt/utc/get";

getUtcNowUnit("year") // "2024"
```

## Source

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