# convertUtcToUnix

Industry: Core

## Signature

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

Convert a UTC Instant string to a unix epoch value in milliseconds or seconds.

- Uses Temporal.Instant.from to parse.
- Seconds floor toward −∞, so `"1969-12-31T23:59:59.5Z"` is second `-1` (POSIX `time_t`).
- `options` must be an object or omitted: a non-object value (such as a bare `"seconds"` string) returns null.
- Returns null for invalid input.

## Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| `value` | `string` | UTC Instant string |

## Options

**options**

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: `"seconds"` or `"milliseconds"`, singular or plural. 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 { convertUtcToUnix } from "@northguild/gmt/utc/convert";

convertUtcToUnix("2024-02-29T00:00:00Z") // 1709164800000
```

## Source

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