Skip to content

Menu

Date and Time Formats Cheat Sheet: ISO 8601, RFC 3339, Unix Time and Time Zones

Checked against Date and time formats RFC 3339, tz database 2026f, Python 3.15 docs; examples run on Python 3.12.8 and Node 24.4.0 on 28 November 2026. Each section links to the official docs it was checked against.

This sheet is for developers who store, send or display timestamps and keep getting bitten by offsets, milliseconds and daylight saving. It covers RFC 3339 (the strict ISO 8601 profile most APIs use), Unix time, IANA time zones as of tz database 2026f, and the Python and JavaScript calls you need. The Python examples ran on 3.12.8 and the JavaScript ones on Node 24.4.0.

When to use what

For anything that crosses a process boundary (APIs, logs, database columns, JSON), send RFC 3339 in UTC with a Z, like 2026-11-28T14:30:00Z. It sorts as text, every language parses it, and nobody has to guess the zone. Use Unix time when you need a compact number, such as a JWT exp claim or a cache key, but write down whether it is seconds or milliseconds: Python and most Unix tools count seconds, JavaScript's Date.now() returns milliseconds.

Keep two ideas apart. An offset (-05:00) is a fact about one instant. A time zone (America/New_York) is a set of rules that gives different offsets on different dates. Store instants in UTC, and store the IANA zone name separately when you need to show local time or schedule something like "9am every Monday" for a user. A fixed offset can't tell you what next summer's offset will be.

In Python, work with aware datetimes (datetime.now(UTC), ZoneInfo) and avoid utcnow(), which is deprecated since 3.12. In JavaScript, Date is fine for instants, and Intl.DateTimeFormat with a timeZone option handles display. Temporal is the long-term fix but MDN still marks it as limited availability, and Node 24.4.0 doesn't expose it, so plan on the polyfill. To convert values by hand, use the Unix timestamp converter or the time zone converter; the time zones and DST post goes deeper on scheduling.

RFC 3339 is a narrow profile of ISO 8601: four-digit years, fixed-width fields, and an offset that is either Z or +HH:MM. ISO 8601 allows much more (week dates, ordinal dates, basic format without separators), which is why "ISO format" alone is not a spec.

2026-11-28T14:30:00Z

UTC instant; Z means the time is in UTC

2026-11-28T09:30:00-05:00

Same instant written with a numeric offset from UTC

2026-11-28T14:30:00.123Z

Fractional seconds are optional and can have any number of digits

2026-11-28 14:30:00Z

A space instead of T is allowed by a note for readability, but strict parsers may reject it

2026-11-28T14:30:00-00:00

-00:00 means the UTC time is known but the local offset is not; it is not the same claim as Z

From the docs, not run by us
2016-12-31T23:59:60Z

Second 60 is legal for a leap second; many libraries reject it

From the docs, not run by us

A 10-digit number is almost certainly seconds and a 13-digit one milliseconds (for dates between 2001 and 2286). Check the length before you convert.

Date.now()

JavaScript: milliseconds since 1970-01-01T00:00:00Z; printed 13 digits on our run

Math.floor(Date.now() / 1000)

JavaScript: current Unix time in seconds, as JWTs and most APIs expect

new Date(1795824000 * 1000)

Seconds to a Date: multiply by 1000 first; this gives 2026-11-28T00:00:00.000Z

new Date(1795824000)

The classic bug: seconds passed as milliseconds lands in January 1970

datetime.fromtimestamp(ts, UTC)

Python: seconds to an aware UTC datetime

datetime.fromtimestamp(ts_ms / 1000, UTC)

Python: divide milliseconds first; passing them raw raised ValueError: year 57878 is out of range for us

Zone names come from the IANA tz database (2026f at the time of writing). Your OS, language runtime or tzdata package ships a copy, so an outdated runtime can show the wrong offset after a country changes its rules.

ZoneInfo("America/New_York")

Python: load a zone by its IANA name; tzname() gave EST for 28 Nov 2026

d.astimezone(UTC)

Convert an aware datetime to UTC; 09:30 New York became 14:30Z

datetime(2026, 11, 1, 1, 30, tzinfo=ny, fold=1)

Pick the second 01:30 when clocks fall back; fold=0 gave -04:00, fold=1 gave -05:00

datetime(2026, 3, 8, 2, 30, tzinfo=ny)

A wall time that doesn't exist (spring-forward gap); Python accepts it silently and maps it to 07:30Z

s + timedelta(days=1)

Adding a day to an aware datetime keeps the wall clock (12:00 to 12:00) across a DST change

(s.astimezone(UTC) + timedelta(hours=24)).astimezone(ny)

Adding 24 real hours across spring-forward lands on 13:00 local instead

Intl.supportedValuesOf('timeZone')

JavaScript: list the IANA zones your runtime knows (418 on Node 24.4.0)

%f and %:z are Python additions, not part of the C11 strftime set, so don't expect them in C or shell date. Locale-dependent codes such as %a and %b change with the user's locale.

datetime.now(UTC)

Current time as an aware datetime in UTC (UTC is an alias added in 3.11)

datetime.fromisoformat('2026-11-28T09:30:00Z')

Parse ISO 8601 including Z (3.11+); returns an aware datetime

d.isoformat()

Format as ISO 8601, e.g. 2026-11-28T09:30:00-05:00

%Y-%m-%dT%H:%M:%S%z

Year, month, day, hour, minute, second and offset without a colon (-0500)

%:z

Offset with a colon (-05:00); strftime since 3.12, strptime since 3.15

%f

Microseconds, zero-padded to six digits

%j %G-W%V-%u

Day of year (332) and ISO week date (2026-W48-6 for Sat 28 Nov 2026)

%Z

Zone abbreviation such as EST; empty for naive datetimes, and strptime only accepts a few values

datetime.strptime(s, '%Y-%m-%dT%H:%M:%S%z')

Parse with an explicit format; %z gives an aware result

Temporal's status is on its own MDN page: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Temporal ("limited availability" on 28 Nov 2026).

new Date('2026-11-28')

Date-only strings are parsed as UTC midnight; in New York getDate() then returned 27

new Date('2026-11-28T00:00')

Date-time strings without an offset are parsed as local time (05:00Z when TZ is New York)

new Date(2026, 10, 28)

Constructor months start at 0, so 10 is November

d.toISOString()

Always UTC with milliseconds: YYYY-MM-DDTHH:mm:ss.sssZ

new Intl.DateTimeFormat('en-US', { timeZone: 'America/New_York', dateStyle: 'medium', timeStyle: 'long' }).format(d)

Show an instant in a named zone; printed Nov 28, 2026, 9:30:00 AM EST

Temporal.ZonedDateTime

Date, time and zone with DST-aware arithmetic; not in Node 24.4.0, use @js-temporal/polyfill

From the docs, not run by us
Temporal.Instant

An exact instant in nanoseconds since the epoch, with no zone

From the docs, not run by us

Worked example: Store a meeting time correctly and show it to two users

A user in New York books a call for 9:30 on 28 Nov 2026. Convert the wall time to an instant on the server and keep the zone name next to it:

from datetime import datetime, UTC
from zoneinfo import ZoneInfo
ny = ZoneInfo('America/New_York')
d = datetime(2026, 11, 28, 9, 30, tzinfo=ny)
print(d.isoformat(), d.tzname())
print(d.astimezone(UTC).isoformat())
2026-11-28T09:30:00-05:00 EST
2026-11-28T14:30:00+00:00

Store 2026-11-28T14:30:00Z and America/New_York. On the client, format the instant for each viewer:

const d = new Date('2026-11-28T14:30:00Z');
new Intl.DateTimeFormat('en-US', {timeZone: 'America/New_York', dateStyle: 'medium', timeStyle: 'long'}).format(d);
new Intl.DateTimeFormat('en-GB', {timeZone: 'Asia/Kolkata', dateStyle: 'full', timeStyle: 'short'}).format(d);
Nov 28, 2026, 9:30:00 AM EST
Saturday, 28 November 2026 at 20:00

The stored UTC value is what you compare, sort and index. The zone name is what lets you rebuild the user's view later, even if their country changes its DST rules before the date. If the meeting repeats weekly, store the local time and zone instead and compute each instant when you need it, because the UTC time of "9:30 New York" moves by an hour twice a year.

Common mistakes

  • Passing Unix seconds to new Date().

    Date expects milliseconds, so seconds land in January 1970. Multiply by 1000, and check whether an API's number has 10 or 13 digits.

  • Storing local times without an offset or zone, like 2026-11-28 09:30.

    Nobody can tell which instant that is. Store UTC with Z, and keep the IANA zone name in another column if local time matters.

  • Saving a fixed offset such as -05:00 as the user's time zone.

    The offset changes with DST. Save America/New_York and let the tz database work out the offset for each date.

  • Using datetime.utcnow() and then calling .timestamp() on it.

    utcnow() returns a naive value and timestamp() treats naive values as local time, so the result is off by your UTC offset. Use datetime.now(UTC).

  • Parsing '2026-11-28' with new Date() and displaying it with local getters.

    It is UTC midnight, which is still the 27th west of Greenwich. Parse date-only values as plain dates (split the string, or use Temporal.PlainDate with the polyfill).

  • Running a daily job at 02:30 local time.

    That time doesn't exist on spring-forward day in many zones and happens twice in autumn in others. Schedule jobs in UTC, or pick an hour outside the DST switch window.