Skip to content

chopUtc

chopUtc(value: string): string
import { chopUtc } from "@northguild/gmt/utc/chop";

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

  • Uses regex to remove trailing “z” or “Z”.
  • Returns “” for invalid input.
Parameter Type Description
value string UTC datetime string (ISO 8601)

UTC datetime string without trailing Z or “” on invalid input

chopUtc("2024-03-10T12:00:00Z") // "2024-03-10T12:00:00"
chopUtc("2024-03-10T12:00:00") // "2024-03-10T12:00:00"
chopUtc("invalid") // ""

utc/chop/chopUtc.ts