Skip to content

parseWeekFromDateTime

  • The core functions, which every industry uses.
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.
ParameterTypeDescription
valuestringISO 8601 datetime string

optionsArg

How weeks are numbered

OptionTypeDefaultDescription
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.

Week number (1-53) or null on invalid input

import { parseWeekFromDateTime } from "@northguild/gmt/plain/parse";
parseWeekFromDateTime("2024-01-01T12:00:00") // 1
output 

plain/parse/parseWeekFromDateTime.ts

Accessibility
© 2026 NorthGuild · Licences

Code examples: MIT-0. Packages: MIT. Third-party data and components: their own licences, credited where they appear. Everything else: © 2026 NorthGuild, all rights reserved.