Skip to content

parseDayOfWeekFromUnix

parseDayOfWeekFromUnix(value: string | number, options?: { epochUnit?: UnixUnit; timeZone?: string; }): number | null

Return the day of week (1-7) from a unix epoch value.

  • Monday=1 through Sunday=7.
  • Returns null for invalid input.
ParameterTypeDescription
valuestring | numberunix epoch in milliseconds or seconds: a safe integer, or a string of optionally negative ASCII digits

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 null.
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 null.

Day of week (1-7) or null on invalid input

import { parseDayOfWeekFromUnix } from "@northguild/gmt/unix/parse";
parseDayOfWeekFromUnix(1704067200000, { timeZone: "UTC" }) // 1
output 

unix/parse/parseDayOfWeekFromUnix.ts