Reference · Marking, scores and game rules
dayKeyfunction
The calendar day a moment falls on, as YYYY-MM-DD: in UTC unless an IANA
time zone such as Asia/Tokyo is named. A name is passed on to Intl, which
throws a RangeError for a zone it does not know.
Import it
import { dayKey } from "@johnmorrisdotca/kotoba";
Definition
function dayKey(moment?: Date | number, zone?: string): DayKey
Parameters
| Name | Type | Description |
|---|---|---|
moment (optional) | number | Date | A Date or Unix milliseconds to interpret. |
zone (optional) | string | undefined | An optional IANA time zone; UTC when omitted. |
Returns
string
The calendar day a moment falls on, as YYYY-MM-DD: in UTC unless an IANA time zone such as Asia/Tokyo is named. A name is passed on to Intl, which throws a RangeError for a zone it does not know.
Examples
import { dayKey } from "@johnmorrisdotca/kotoba";
console.log(dayKey(new Date("2026-10-12T12:00:00Z")));2026-10-12What it prints (run when this page was built)