Skip to content

chopMilliseconds

chopMilliseconds(value: string): string

Return a string with millisecond precision removed from a PlainDateTime or PlainTime value.

  • Truncates to second precision.
  • Accepts both PlainDateTime and PlainTime formats.
  • Returns "" for invalid input.
ParameterTypeDescription
valuestringISO PlainDateTime or PlainTime string

ISO string without milliseconds, or "" on invalid input

import { chopMilliseconds } from "@northguild/gmt/plain/chop";
chopMilliseconds("2024-02-29T12:34:56.789") // "2024-02-29T12:34:56"
output 

plain/chop/chopMilliseconds.ts