Skip to content

parseYearMonthFromDate

parseYearMonthFromDate(value: string): string

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

  • The day is dropped, so 2026-10-01 and 2026-10-31 give the same year-month.
  • Only the ISO calendar is read; a Hebrew or Islamic date gives "".
  • Returns "" for invalid input.
ParameterTypeDescription
valuestringISO date string

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

import { parseYearMonthFromDate } from "@northguild/gmt/plain/parse";
parseYearMonthFromDate("2026-10-01") // "2026-10"
output 

plain/parse/parseYearMonthFromDate.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.