Skip to content

chopUtc

chopUtc(value: string): string

Return the UTC datetime string with a trailing Z removed if present.

  • Removes the trailing “Z”; a lower-case “z” is not a GMT UTC string (isValidUtc), so it returns "".
  • Drops the RFC 9557 annotations Temporal.Instant.from ignores ([foo=bar], [Europe/Paris]).
  • Returns "" for invalid input.
ParameterTypeDescription
valuestringUTC datetime string (ISO 8601)

UTC datetime string without trailing Z or "" on invalid input

import { chopUtc } from "@northguild/gmt/utc/chop";
chopUtc("2024-03-10T12:00:00Z") // "2024-03-10T12:00:00"
output 

utc/chop/chopUtc.ts