# convertZonedToUnix

Industry: Core

## Signature

```ts
convertZonedToUnix(value: string, options?: { epochUnit?: UnixUnit; }): number | null
```

Convert an ISO 8601 zoned datetime string to a unix epoch value in milliseconds (default) or seconds.

- Uses Temporal.ZonedDateTime.toInstant to convert.
- Seconds floor toward −∞, as POSIX `time_t` counts whole elapsed seconds.
- A non-object `options` (such as a bare `"seconds"` string) returns null.
- Returns null for invalid input.

## Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| `value` | `string` | zoned ISO 8601 datetime string |

## Options

**options**

optional setting for the unit of the returned epoch value

| Option | Type | Default | Description |
| --- | --- | --- | --- |
| `epochUnit?` | `"seconds"` \| `"milliseconds"` \| `"second"` \| `"millisecond"` ([`UnixUnit`](/gmt/reference/types/UnixUnit/)) | `"milliseconds"` | The unit the epoch value is returned in: `"milliseconds"` or `"seconds"`, each also accepted in its singular form. An explicit `undefined` is the same as omitted; any other value returns null. |

## Returns

epoch number or null on invalid

## Related types

- [`UnixUnit`](/gmt/reference/types/UnixUnit/)

## Examples

```ts
import { convertZonedToUnix } from "@northguild/gmt/zoned/convert";

convertZonedToUnix("2024-02-29T12:34:56.789+00:00[UTC]") // 1709210096789
```

## Source

[zoned/convert/convertZonedToUnix.ts](https://github.com/northguild/gmt/blob/main/packages/gmt/src/zoned/convert/convertZonedToUnix.ts)
