# Getting Current Date / Time

Industry: Core

Use these functions when you need "now" in a specific shape. They are the starting
point for almost every other operation — arithmetic, comparison, formatting.

## Get the current local date or datetime

```typescript
import { getNow, getToday } from "@northguild/gmt";

getToday(); // "2024-03-15" — current date in the system timezone
getNow(); // "2024-03-15T14:30:45.123456789" — current datetime in the system timezone
```

Both resolve "now" in the **system timezone**. For deterministic results regardless
of the host machine's timezone, use the zoned variants with an explicit zone.

## Get the current UTC date or datetime

```typescript
import { convertUtcToPlainDate, getUtcNow } from "@northguild/gmt/utc";

getUtcNow(); // "2024-03-15T18:30:45.123456789Z"
convertUtcToPlainDate(getUtcNow()); // "2024-03-15" — the current date in UTC
```

There is no separate "UTC today" accessor: `convertUtcToPlainDate` takes the date of a UTC
instant, in UTC unless you pass `{ timeZone }`.

## Get the current Unix timestamp

```typescript
import { getUnixNow } from "@northguild/gmt/unix";

getUnixNow(); // 1710527445123 — milliseconds since epoch
getUnixNow({ epochUnit: "seconds" }); // 1710527445 — seconds since epoch
```

`getUnixNow` returns **milliseconds** unless you pass `{ epochUnit: "seconds" }`. Name the unit the
consumer expects — and be consistent: mixing the two is a common source of
1000x errors.

## Get the current time in a specific timezone

```typescript
import { getZonedNow, getZonedToday } from "@northguild/gmt/zoned";

getZonedNow("Africa/Johannesburg"); // "2024-03-15T14:30:45.123+02:00[Africa/Johannesburg]"
getZonedToday("Asia/Tokyo"); // "2024-03-16"
```

## Get the system timezone and the list of all IANA zones

```typescript
import { getSystemTimeZone, getTimeZones } from "@northguild/gmt/zoned";

getSystemTimeZone(); // "Europe/London"
getTimeZones(); // ["Africa/Abidjan", "Africa/Accra", ...] — 418 entries on Node.js 24
```

`getTimeZones()` returns every IANA zone the runtime's ICU data knows about. The
count varies by runtime.

## Count a length of time from now

`getDateIn`, `getDateTimeIn`, `getTimeIn`, `getUtcIn`, `getUnixIn` and `getZonedIn` count a length
forward from the clock. Their `Ago` pairs count back. Each takes a unit object, such as
`{ days: 90 }`:

```typescript
import { getDateIn, getUtcAgo, getZonedIn } from "@northguild/gmt";

// With a clock at 2027-06-15T12:07:30Z:
getDateIn({ days: 3 }); // "2027-06-18"
getUtcAgo({ days: 90 }); // "2027-03-17T12:07:30Z"
getZonedIn("Europe/Paris", { days: 1 }); // "2027-06-16T14:07:30+02:00[Europe/Paris]"
```

- The plain pairs (`getDateIn`, `getDateTimeIn`, `getTimeIn`) start from the **system timezone**,
  as `getToday` does, so `getDateIn({ days: 0 })` equals `getToday()`. The UTC, Unix and from-now
  functions count in UTC, so their result does not change with the server's zone.
- `getTimeIn` wraps at midnight and carries no date: `getTimeIn({ hours: 13 })` from 12:07:30 is
  `"01:07:30"`.
- A negative amount returns the sentinel (`""` or `null`), because the name gives the direction.
- The string forms write whole seconds, floored. For a length as a number of seconds, an HTTP date
  or a cookie lifetime, see [Durations](../durations/#a-length-of-time-counted-from-now).

## Using Temporal directly

When you need the current value as a Temporal object for further manipulation
(rather than a string), use `Temporal.Now` directly:

```typescript
import { Temporal } from "@northguild/gmt";

Temporal.Now.instant(); // Temporal.Instant — absolute point in time
Temporal.Now.plainDateISO(); // Temporal.PlainDate — system timezone
Temporal.Now.plainDateTimeISO(); // Temporal.PlainDateTime — system timezone
Temporal.Now.zonedDateTimeISO("Australia/Sydney"); // Temporal.ZonedDateTime
```

These are the same `Temporal` objects GMT's functions read, so you can pass a value
between them and a GMT function.

## See also

- [Plain Arithmetic](../plain-arithmetic/) — adding, subtracting, and diffing dates
- [Zoned Operations](/gmt/guides/zoned-date-operations/zoned-operations/) — "now" in a specific zone
- [`getNow` reference](/gmt/reference/plain/get/getNow/)
- [`getZonedNow` reference](/gmt/reference/zoned/get/getZonedNow/)
- [`getUnixNow` reference](/gmt/reference/unix/get/getUnixNow/)
- [`getUtcIn` reference](/gmt/reference/utc/get/getUtcIn/)
- [`getZonedIn` reference](/gmt/reference/zoned/get/getZonedIn/)
