Skip to content

convertUnixToPlainDateTime

  • The core functions, which every industry uses.
convertUnixToPlainDateTime(value: string | number, options?: { epochUnit?: UnixUnit; timeZone?: string; }): string

Convert a Unix timestamp to a plain datetime string in the format “YYYY-MM-DDTHH:mm:ss”.

  • Converts to PlainDateTime in timeZone.
  • value is a safe integer or a string of optionally negative ASCII digits; anything else returns "".
  • Returns "" for invalid input.
ParameterTypeDescription
valuestring | numberUnix epoch: a safe integer or a digit string

options

optional: how value is read and the zone its wall clock is read in

OptionTypeDefaultDescription
epochUnit?"seconds" | "milliseconds" | "second" | "millisecond" (UnixUnit)"milliseconds"The unit the epoch values are counted in: "seconds" or "milliseconds", singular or plural. Any other value returns "".
timeZone?string"UTC"The time zone the wall-clock fields are read in: an IANA name, a UTC offset (a time zone identifier such as +05:30, +0530 or -08, or a stored offset ±HH:MM[:SS], what getTimeZoneOffset returns), or "local" for the system time zone. An unknown zone returns "".

plain datetime string in “YYYY-MM-DDTHH:mm:ss” format or "" on invalid input

import { convertUnixToPlainDateTime } from "@northguild/gmt/unix/convert";
convertUnixToPlainDateTime(1709164800000, { timeZone: "UTC" }) // "2024-02-29T00:00:00"
output 

unix/convert/convertUnixToPlainDateTime.ts

Accessibility
© 2026 NorthGuild · Licences

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.