Reads a string, timestamp, fields object, or calendar date into a DateTime viewed in a time zone. Omit the time zone to use your configured default or the runtime’s local zone.
ISO string, epoch milliseconds, Date, fields object, calendar date, or Temporal value.
zoneOrOptionsZone | ReadOptions
Time zone string such as 'Europe/Berlin' or 'UTC', or an options object.
4 options
zoneZone
Time zone to view the moment in, overriding any bracketed zone in input.
localeLocale
BCP 47 locale tag carried on the returned DateTime and every value derived from it.
loosebooleandefault false
Parse informal date strings and return null on unreadable input with @native-dates/plugins/loose.
dayFirstboolean
Override the active locale's numeric date order for strings like '07/09/2026' in loose mode.
Returns
DateTime
A DateTime in the resolved time zone, or null when loose mode cannot read input.
When @native-dates/plugins/loose is imported, loose mode reads informal dates and times in the active locale, falls back to engine parsing for machine formats, and returns null on unreadable input:
import { datetime } from 'native-dates';import '@native-dates/plugins/loose';datetime('Mon, 16 Nov 2026 17:30:00 GMT', { zone: 'America/New_York', loose: true });datetime('not a timestamp', { loose: true }); // null
Accepted inputs
Every input produces an immutable instance viewed in the target time zone:
Input
Example
How it reads
ISO string with offset
'2026-11-16T17:30:00Z', '2026-11-16 12:30-05:00'
Fixes the exact moment and views it in the target time zone.
Bracketed zone string
'2026-11-16T09:30[America/New_York]'
Keeps the bracketed zone unless a second zone argument overrides it.
Local date and time
'2026-11-16T09:30', '2026年11月16日 14:30'
Reads a year-first date and time of day directly in the target zone.
Starts at the beginning of that calendar day in the target zone.
Milliseconds or Date
1794850200000, new Date()
Converts the Unix timestamp to the target zone, truncating fractional milliseconds like Date.
Fields object
{ year: 2026, month: 11, day: 16, hour: 9 }
Reads 1-indexed calendar and clock fields in the target zone and rejects impossible dates.
DateTime or Temporal
dt, Temporal.Instant, Temporal.ZonedDateTime
Preserves an existing zone unless an explicit zone argument is passed.
Missing values never become now
Missing values such as undefined or null throw an error so an empty database column never turns into the current time by accident. Call now() when you want the live clock.
Current moment and today
Read the live clock or build query bounds for the current day in any time zone.
now()
now(zone?): DateTime
Returns the current moment at millisecond precision in the given time zone or your configured default. Millisecond precision matches Date.now(), so timestamps round-trip through JSON payloads unchanged.
Parameters
zoneZone
Time zone to view the current moment in, such as 'Asia/Tokyo' or 'UTC'.
Returns
DateTime
A DateTime for the current millisecond in zone.
import { now } from 'native-dates';const local = now();const tokyo = now('Asia/Tokyo');const utc = now('UTC');
startOfToday()
startOfToday(zone?): DateTime
Returns the start of today in the given time zone, matching the beginning of the local calendar day. Useful as the lower bound when querying events or records created today.