Unix time, milliseconds and the timezone traps
Why the same instant appears as ten or thirteen digits, why the date field and the server disagree, and how to read a timestamp without introducing an off-by-one-day bug.
2026-12-01
Ten digits or thirteen: the first thing to check
Unix time counts seconds since 1970-01-01T00:00:00Z. In 2026 that is ten digits, for example 1764547200. JavaScript, Java and many APIs use milliseconds instead, which is the same instant with three more digits. A log that mixes the two units looks harmless until a date lands in 1970 or in the year 56000.
The quick check is length. Ten digits is seconds, thirteen is milliseconds, and anything in between deserves a second look. Values from before September 2001 are under 10¹² even in milliseconds, so a very old millisecond value can be mistaken for seconds; when the year looks plausible but the day is wrong, suspect the unit before suspecting the conversion.
UTC is the reference, local time is a rendering
A Unix value has no timezone. It is an instant, and every correct rendering of it points to the same moment. Storing local time strings is where systems break: a server in Frankfurt and a browser in Tokyo both read 18:00 from the same string and mean different instants.
Store UTC, render in the user's timezone at the edge. That is also why a timestamp converter shows the ISO string with a Z first and the local line second. If two people compare the same number, the ISO line is the only one guaranteed to match.
Daylight saving makes some times impossible
In a timezone with daylight saving, one hour in spring does not exist and one hour in autumn happens twice. A local timestamp such as 2026-03-29 02:30 in central Europe cannot be mapped to a single instant, and different libraries resolve it differently: some move forward, some pick the earlier offset.
This is not a theoretical edge case. Scheduled jobs, birthdays and expiry checks that use local strings near a DST boundary can run twice or not at all. Keeping the canonical value in UTC removes the ambiguity; the local string is only for display.
ISO 8601 strings are not all equal
2026-12-01T18:00:00Z is unambiguous. 2026-12-01T18:00:00+02:00 is also unambiguous and represents 16:00 UTC. But 2026-12-01T18:00:00 without an offset is local time, and 2026-12-01 without a time is treated as UTC midnight by JavaScript. Three strings that look similar can mean three different instants.
When an API returns a date without an offset, the safe assumption is that the backend has a convention, not that the timezone is irrelevant. Check the documentation, or compare the value with a known event before building logic on it. Guessing produces reports that are correct for eleven months and wrong for one.
A short verification routine
Convert a timestamp and check three things: the ISO line ends with Z, the local line matches what you expect on your own clock, and the unit note says seconds or milliseconds. If any of the three is off, stop before pasting the value into a database or a test fixture.
Useful anchors: 0 is 1970-01-01T00:00:00Z, 1000000000 is 2001-09-09T01:46:40Z, and 1764547200 is a date in December 2026. If a converter disagrees with these anchors, the problem is the input unit or the timezone, not the arithmetic.