Reference · Dates

date.to_zone

signature
date.to_zone(str, str | null=) -> str

What it does

The same instant written at a time zone's offset: "2026-10-27T14:30:00Z" in "Europe/Paris" is "2026-10-27T15:30:00+01:00". The zone is an IANA name, in any case, "UTC", or a fixed offset like "+05:30", "+0530" or "+05" (see date.valid_zone); left out, it is UTC, which turns any date-time into its UTC form. A named zone's offset follows daylight saving on that day. It takes a date-time; a date has no instant to move.

Examples

print(date.to_zone("2026-10-27T14:30:00Z", "Europe/Paris"))print(date.to_zone("2026-10-27T14:30:00Z", "America/New_York"), date.to_zone("2026-10-27T14:30:00Z", "Asia/Kolkata"))print(date.to_zone("2026-10-27T15:30:00+01:00"))
output
2026-10-27T15:30:00+01:002026-10-27T10:30:00-04:00 2026-10-27T20:00:00+05:302026-10-27T14:30:00Z

Edge cases

print(date.to_zone("2026-10-27T23:30:00Z", "Pacific/Auckland"), date.to_zone("2026-10-27T02:30:00Z", "Pacific/Honolulu"))print(date.to_zone("2026-07-01T12:00:00Z", "Europe/Paris"), date.to_zone("2026-12-01T12:00:00Z", "Europe/Paris"))print(date.to_zone("2026-10-27T14:30:00+00:00", "utc"), date.to_zone("2026-10-27T14:30:00.250Z", "-03:00"))print(date.to_zone("2026-10-27T14:30:00Z", "Europe/Paris") == "2026-10-27T14:30:00Z")print(date.to_zone("1900-01-01T00:00:00Z", "Europe/Paris"))
output
2026-10-28T12:30:00+13:00 2026-10-26T16:30:00-10:002026-07-01T14:00:00+02:00 2026-12-01T13:00:00+01:002026-10-27T14:30:00Z 2026-10-27T11:30:00.250-03:00false1900-01-01T00:09:21+00:09:21

Errors

A date instead of a date-time, text that is neither, an unknown zone, an offset that is not +HH:MM ("+5", "+25:00"), or a result outside years 1 to 9999 is a runtime error, not an error value.

this one fails
print(date.to_zone("2026-10-27", "Europe/Paris"))
output
line 1: `date.to_zone` expects a date-time (like 2026-10-27T14:30:00Z) as argument 1, got "2026-10-27"
this one fails
print(date.to_zone("2026-10-27T14:30:00Z", "Europe/Nowhere"))
output
line 1: `date.to_zone`: unknown time zone "Europe/Nowhere"

Chaining

The date-time comes first, so a stored UTC time is shown in a zone and formatted in one line:

print("2026-10-27T14:30:00Z" | date.to_zone("Asia/Tokyo") | date.format("HH:mm Z"))print(date.from_ms(1793111400000) | date.to_zone("Europe/Lisbon") | date.parts | (p) => p.hour)
output
23:30 +09:0014

See also

date.date_in, date.at, date.from_ms, date.ms, date.format, date.now

Thread
6Useful? Like it, or add to its thread below.

Thread 0 posts

On date.to_zone(): questions, tips, corrections, and code that uses it.

No posts yet. The first one opens the thread.

    Edit this page on GitHub · every example's output was made by running it (tools/refcheck.mjs) · questions on Discord or r/quillo