# parseWeekFromDateTime

Industry: Core

## Signature

```ts
parseWeekFromDateTime(value: string, optionsArg?: { weekStartsOn?: "monday" | "sunday"; }): number | null
```

Return the week number for a given ISO 8601 datetime string.

- The week is the week of the week-year, 1–53, under either numbering — see `getWeekNumber`.
- Returns null for invalid input.

## Parameters

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

## Options

**optionsArg**

How weeks are numbered

| Option | Type | Default | Description |
| --- | --- | --- | --- |
| `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) or null on invalid input

## Examples

```ts
import { parseWeekFromDateTime } from "@northguild/gmt/plain/parse";

parseWeekFromDateTime("2024-01-01T12:00:00") // 1
```

## Source

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