Skip to content

parseYearMonthFromDateTime

parseYearMonthFromDateTime(value: string): string

Return the year-month (YYYY-MM) of an ISO 8601 date-time string.

  • The day and the time are dropped, so the time never moves the month.
  • A Z or an offset gives ""; a time zone annotation with no offset is ignored, as isValidDateTime reads it.
  • Only the ISO calendar is read.
  • Returns "" for invalid input.
ParameterTypeDescription
valuestringISO date-time string

The canonical YYYY-MM string (±YYYYYY-MM outside 0000-9999), or "" on invalid input

import { parseYearMonthFromDateTime } from "@northguild/gmt/plain/parse";
parseYearMonthFromDateTime("2026-10-01T10:00:00") // "2026-10"
output 

plain/parse/parseYearMonthFromDateTime.ts

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.