Guides Development

How Dates and Time Zones Work

UTC, offsets and time zones, daylight saving, Unix time and the 2038 problem, leap years, week numbers and day counts, with every example run in code.

Last reviewed:

AdSense Placeholder
Slot: header_reference_page
On this page

Dates look simple until you cross a time zone, a daylight-saving change or a New Year boundary. This guide covers the handful of ideas that explain nearly every bug and calculator result.

UTC, offsets and time zones

UTC is the global reference clock. A UTC offset such as +02:00 says how far a local clock is ahead of it. A time zone is a region with a history of offsets (for example America/New_York or Europe/Berlin), which is why it is not the same thing: New York is −05:00 in winter and −04:00 in summer. Time zones are political and sometimes odd: India is +05:30 and Nepal is +05:45.

Daylight saving time moves the gap

A meeting at 15:00 in New York on 3 October 2026 is 21:00 in Berlin, a 6-hour gap because both are on summer time. Europe ends daylight saving on 25 October and the US on 1 November, so on 28 October, with only Berlin on winter time, the same 15:00 New York meeting is 20:00 in Berlin, a 5-hour gap. From 1 November onwards the gap is 6 hours again. The Time Zone Calculator handles these shifts; just do not hard-code an offset.

Rule: store and compute in UTC, convert to local time only for display, and always keep the zone name rather than a fixed offset.

Unix time and the year 2038

Computers often keep time as seconds since 1970-01-01T00:00:00Z, called Unix time. It ignores leap seconds and time zones, so it is the same number everywhere. A signed 32-bit counter runs out at 2^31 − 1 = 2,147,483,647 seconds, which is January 19, 2038 at 03:14:07 UTC: the "year 2038 problem" for old software. Modern systems use 64 bits. Convert values with the Unix Timestamp Converter.

Leap years

A year is a leap year if it is divisible by 4, except century years, unless divisible by 400. So 2024 and 2000 are leap years while 1900 and 2100 are not. Someone born on 29 February has a true birthday only every fourth year; in other years it is celebrated on 28 February or 1 March, depending on local custom and law.

Counting days and ages

  • Days between dates: the Day Counter and Date Calculator count from 1 March to 3 October 2026 as 216 days when the start day is excluded; add 1 if both ends count.
  • Age: it is the number of whole years elapsed: someone born on 28 February 1990 is 36 on 3 October 2026. The Age Calculator also gives months and days.
  • Weekday: use the Day of the Week Calculator. 3 October 2026 is a Saturday.
  • Week numbers: ISO weeks start on Monday, and week 1 contains the year's first Thursday. 3 October 2026 is in week 40; use the Week Number Calculator. Days near New Year can belong to the other year's week.

Durations and clocks

Common mistakes

  • Treating a day as 24 hours. On daylight-saving days it can be 23 or 25.
  • Storing local times without a zone. The same string means different instants in different places.
  • Parsing 03/10/2026 without knowing the order. Prefer ISO 8601 (2026-10-03); see the Date & Time Formats Cheat Sheet.
  • Off-by-one day counts. Decide whether the start, the end or both days count, and say so.

Try these tools

See also

  • Cheat sheet Date & Time Formats Cheat Sheet
    ISO 8601 patterns, strftime codes, Unix time units and the leap-year, week-number and daylight-saving traps.
  • Glossary Unix timestamp
    A Unix timestamp is the number of seconds since 00:00:00 UTC on 1 January 1970, the "Unix epoch".
  • Glossary UTC
    UTC is the global reference time standard from which all time zones are defined as offsets.

Frequently Asked Questions

For everyday use they are the same time. UTC is the precise scientific standard kept by atomic clocks; GMT is the older time zone based on the Sun at Greenwich, used today as the winter time of the United Kingdom.

AdSense Placeholder
Slot: footer_leaderboard