Skip to content

convertZonedToPlainDateTime

convertZonedToPlainDateTime(value: string): string

Convert a zoned ISO 8601 datetime string to a plain datetime string.

  • Extracts the local date-time components without timezone info.
  • Validation is performed on the input.
  • The offset is dropped, and with it which occurrence of a repeated wall time was meant. In a fall-back overlap the same plain date-time names two instants; converting back with convertPlainDateTimeToZoned picks the earlier one by default. Keep the zoned string, or pass { disambiguation: "later" } when converting back, to recover the second occurrence.
ParameterTypeDescription
valuestringzoned ISO 8601 datetime string

plain datetime string or "" on invalid input

import { convertZonedToPlainDateTime } from "@northguild/gmt/zoned/convert";
convertZonedToPlainDateTime("2024-02-29T14:30:45.123-05:00[America/New_York]") // "2024-02-29T14:30:45.123"
output 

zoned/convert/convertZonedToPlainDateTime.ts