# parseWeekFromUnix

Industry: Core

## Signature

```ts
parseWeekFromUnix(value: string | number, options?: { epochUnit?: UnixUnit; timeZone?: string; weekStartsOn?: "monday" | "sunday"; }): number | null
```

Return the week number from a unix epoch value.

- Returns the week of the week-year, 1–53, so late-December days can be week 1 of the next year — see `getWeekNumber`.
- Returns null for invalid input.

## Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| `value` | `string` \| `number` | unix epoch in milliseconds or seconds: a safe integer, or a string of optionally negative ASCII digits |

## Options

**options**

optional: how `value` is read, the zone its date is read in and the first day of the week; a non-object value (such as `null`) is invalid

| Option | Type | Default | Description |
| --- | --- | --- | --- |
| `epochUnit?` | `"seconds"` \| `"milliseconds"` \| `"second"` \| `"millisecond"` ([`UnixUnit`](/gmt/reference/types/UnixUnit/)) | `"milliseconds"` | The unit the epoch values are counted in: `"seconds"` or `"milliseconds"`, singular or plural. Any other value returns `null`. |
| `timeZone?` | `string` | `"UTC"` | The time zone the date is read in: an IANA name, a UTC offset (a time zone identifier such as `+05:30`, `+0530` or `-08`, or a stored offset `±HH:MM[:SS]`, what `getTimeZoneOffset` returns), or `"local"` for the system time zone. An unknown zone returns `null`. |
| `weekStartsOn?` | `"monday"` \| `"sunday"` | `"monday"` | The first day of the week, which sets how the week is numbered. `"monday"` gives the ISO 8601 week number, where week 1 holds the year's first Thursday; `"sunday"` gives the UTS #35 week number with a Sunday first day and one minimal day, where week 1 holds 1 January. Any other value returns `null`. |

## Returns

Week number (1-53 for "monday" and for "sunday") or null on invalid input

## Related types

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

## Examples

```ts
import { parseWeekFromUnix } from "@northguild/gmt/unix/parse";

parseWeekFromUnix(1704067200000, { timeZone: "UTC" }) // 1
```

## Source

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