Temporal API
Get the current date
const date = Temporal.Now.plainDateISO(); // 2025-01-31Return the date in ISO 8601 date format
date.toString(); // "2025-01-31"Get current date and time in ISO 8601 format
Temporal.Now.plainDateTimeISO().toString(); // "2025-01-31T10:51:40.269979904"Get Unix timestamp
const timeStamp = Temporal.Now.instant(); // 2025-01-31T18:51:59.093355008ZReturn timestamp in milliseconds
timeStamp.epochMilliseconds; // 1738349519093Get date and time in ISO 8601 format from milliseconds
const futureTime = Temporal.Instant.fromEpochMilliseconds(1851222399924); // 2028-08-30T04:26:39.924ZMeasure difference in hours from now.
const now = Temporal.Now.instant();
now.until(futureTime, { smallestUnit: "hour" }); // PT31600HRun this example locally using the Deno CLI:
deno run https://docs.deno.com/examples/scripts/temporal.ts