Unix timestamps, ISO 8601 and time zones: a developer’s guide

How to store, convert and display dates and times correctly — Unix time, ISO 8601, UTC vs local time, IANA time zones, daylight saving pitfalls and scheduling future events.

Dates and times look simple until a booking appears an hour early for half your customers, a report counts a day twice, or a reminder fires at 3 a.m. Most time bugs come from a handful of misunderstandings: confusing a moment with a wall-clock time, using fixed offsets instead of time zones, and forgetting that daylight saving rules change.

This guide explains the concepts and formats you need, and a set of rules that prevent most problems. Our Unix timestamp converter and time zone meeting planner let you check every example in your browser.

Two different things: instants and wall-clock times

The most important distinction in time handling is between:

  • An instant: a single point on the global timeline, the same everywhere. “The moment the order was paid.”
  • A wall-clock time (or local date-time): what a clock on the wall shows somewhere. “09:00 on 3 March”, without saying where.

An instant can be shown as different wall-clock times in different places. A wall-clock time only becomes an instant when you add a time zone.

Many bugs come from storing one when you meant the other.

Unix time

Unix time (also called epoch time or a POSIX timestamp) counts seconds since 00:00:00 UTC on 1 January 1970, the “Unix epoch”. It represents an instant and is the same number everywhere in the world at a given moment.

  • It is compact, easy to compare and sort, and free of time-zone ambiguity.
  • It is not human-readable without conversion.
  • It does not count leap seconds: each day is treated as exactly 86,400 seconds.

Seconds or milliseconds?

Different systems use different units:

UnitTypical digits todayUsed by
Seconds10Unix tools, many APIs, JWT claims
Milliseconds13JavaScript Date.now(), Java
Microseconds16Some databases and logging systems
Nanoseconds19Some languages and high-precision systems

Feeding a seconds value into a function that expects milliseconds gives a date in January 1970; the reverse gives a date tens of thousands of years in the future. The converter detects the unit from the number of digits and tells you what it assumed.

The year 2038 problem

Systems that store Unix time as a signed 32-bit integer can count only up to 2,147,483,647 seconds, which is 03:14:07 UTC on 19 January 2038. One second later the value overflows. Modern operating systems, languages and databases generally use 64-bit values, but embedded devices, old file formats and legacy database columns may not. If your software handles dates far into the future — mortgages, warranties, long subscriptions — check your storage types.

UTC and offsets

UTC (Coordinated Universal Time) is the global reference time. It doesn’t observe daylight saving time. Local times are often described as an offset from UTC, such as UTC+05:30 or UTC−03:00.

An offset tells you how a local time relates to UTC at one moment. It does not tell you what the offset will be next month, because daylight saving changes it.

Time zones: use names, not offsets

A time zone is a region that follows the same rules for local time over history, including when and whether it observes daylight saving time. The standard reference is the IANA time zone database (often called tzdata or the Olson database), which uses names like:

  • Europe/London
  • America/New_York
  • Asia/Kolkata
  • Australia/Sydney
  • America/Sao_Paulo

These names carry the full rules, including historical changes. “UTC+1” doesn’t: it can’t tell you that a city switches to UTC+2 in summer.

Abbreviations like EST, IST or CST are ambiguous — IST, for example, is used for more than one zone — so avoid them in data and APIs.

Time-zone rules change when governments change them, sometimes at short notice. Operating systems, browsers and language runtimes ship updated copies of the IANA database, so keep them updated.

ISO 8601 and RFC 3339

ISO 8601 is the international standard for writing dates and times. RFC 3339 is a stricter profile of it widely used on the internet. Typical forms:

2026-11-28                      a date
2026-11-28T14:30:00Z            an instant in UTC (Z means UTC)
2026-11-28T14:30:00+05:30       an instant with its offset
2026-11-28T14:30:00             a local date-time with no zone (ambiguous on its own)

Benefits:

  • Sorting the strings alphabetically sorts them chronologically (for the same format and offset).
  • Year-month-day order avoids the confusion between day/month and month/day conventions.
  • Most languages parse it directly.

An offset in an ISO string identifies the instant, but not the time zone. If you need to know the zone — for example, to show future times correctly — store the IANA name separately.

Daylight saving time: gaps and overlaps

In zones that observe daylight saving time:

  • Spring forward. Clocks jump ahead, typically by an hour. Some local times don’t exist that day — the “gap”.
  • Fall back. Clocks go back. Some local times happen twice — the “overlap”.

This causes bugs such as:

  • A daily job scheduled at 02:30 local time not running, or running twice.
  • “Add 24 hours” and “add one day” giving different results across a transition.
  • Durations calculated from local times being an hour wrong.

Not every country observes daylight saving, transitions happen on different dates in different countries, and the southern hemisphere changes in the opposite season to the northern. Don’t hard-code rules; let a time-zone library apply the IANA data. Our cron expressions guide covers how this affects scheduled jobs.

Rules that prevent most bugs

1. Store past events as instants in UTC

For things that have happened — payments, log entries, sign-ups — store an instant: a UTC timestamp or a database type designed for instants. Convert to local time only when displaying.

2. Store future local events as local time plus zone

For future events defined by local time — a meeting at 09:00 in Berlin next July, a restaurant booking, a class timetable — store the local date-time and the IANA zone name, not just a UTC instant. If the country changes its time-zone rules before then, the event still happens at 09:00 local time. Compute the UTC instant when you need it.

This is especially important for booking systems, where customers care about the local time printed on their ticket.

3. Use time-zone-aware types and libraries

Use your platform’s time-zone-aware types and a well-maintained library rather than hand-written offset arithmetic. In browsers, the built-in Intl.DateTimeFormat API formats instants in any IANA zone and is what our tools use.

4. Be explicit at boundaries

APIs, CSV exports and logs should use unambiguous formats: ISO 8601 with Z or an offset, or Unix time with the unit documented. Never exchange local times without a zone.

5. Separate dates from instants

A birthday, a public holiday or an invoice due date is a date, not a moment. Storing it as midnight UTC can make it display as the previous day for users west of UTC. Use a date-only type.

6. Test the awkward cases

Add tests for daylight saving transitions in zones you support, month ends, leap years (29 February), the end of the year, and users far east and far west of your server.

Scheduling meetings across time zones

For people rather than computers, the challenge is finding times that work for everyone. A few practical tips:

  • Always state the time with the zone or city: “14:00 London (UTC+0)”.
  • Send calendar invitations rather than plain text; calendar apps convert to each person’s zone.
  • Watch for the weeks when countries change their clocks on different dates, as the usual overlap can shift by an hour.
  • If there is no comfortable overlap, rotate meeting times so the early or late slot is shared fairly.

Our time zone meeting planner shows each participant’s local time hour by hour and highlights the hours that fall inside everyone’s working day.

Leap seconds, briefly

UTC has occasionally added a leap second to stay aligned with the Earth’s rotation. Unix time ignores them, and most software never sees them directly; systems typically handle them by repeating or smearing a second. In 2022 the international timekeeping community decided to stop adding leap seconds by or before 2035. For almost all business software, they are not something to design around.

Generating identifiers that sort by time

If you want database IDs that sort by creation time, UUID version 7 embeds a millisecond Unix timestamp at the start. Our UUID generator creates them and can read the timestamp back out of an existing one.

If your app has scheduling, bookings or international users and you want date handling done right from the start, KRA Digital can help with web application development. For more definitions, see our web development glossary.

Frequently asked questions

What is a Unix timestamp?

The number of seconds that have elapsed since 00:00:00 UTC on 1 January 1970, not counting leap seconds. It identifies an instant and is the same everywhere in the world at a given moment.

How do I tell if a timestamp is in seconds or milliseconds?

For current dates, a value in seconds has 10 digits and a value in milliseconds has 13. Our timestamp converter detects this automatically and shows the date it represents.

Should I store dates in UTC?

Store past events as UTC instants. For future events tied to local time, such as appointments, store the local date-time with an IANA time-zone name, because time-zone rules can change before the event happens.

Why use “Europe/Paris” instead of “UTC+1”?

A named time zone includes daylight saving rules and historical changes. A fixed offset is only correct for part of the year in zones that observe daylight saving time.

What is ISO 8601?

An international standard for representing dates and times, such as 2026-11-28T14:30:00Z. It puts the largest unit first, avoids day/month confusion and is understood by most programming languages.

Let’s build something great.

Tell us what you want to build, who it is for and what it needs to do. We’ll help you define a practical next step.

Start a project