How Unix timestamps are converted

Last updated 2026-11-29

Four rules decide every result on this page: what the number counts, how seconds are told apart from milliseconds, how the output is rendered, and where the arithmetic stops being exact.

1. What the number counts

A Unix timestamp is one integer: the number of seconds elapsed since 00:00:00 UTC on 1 January 1970, with leap seconds left out. It carries no time zone, no calendar system and no daylight-saving flag. 1760000000 and 1760000000000 describe the same instant at different precisions; only the digits differ.

timestamp (s) = (instant − 1970-01-01T00:00:00Z) ÷ 1 second

Because the epoch is defined in UTC, the same moment produces the same number in Shanghai, London and New York. Only the rendering changes. That is why timestamps are safe to store, sort and send between systems, while formatted date strings are not.

Store the number, not the text. Convert to a local date only when the value is displayed, and keep UTC in logs and databases.

2. Seconds or milliseconds: the 1e12 cut-off

Millisecond timestamps are 1000 times larger, so they need three more digits. The converter does not ask which unit you mean. It applies a numeric rule: anything below 1,000,000,000,000 is read as seconds, anything at or above it as milliseconds. Ten-digit input is therefore seconds, thirteen-digit input is milliseconds, and that covers nearly every API and database you will meet.

milliseconds = seconds × 1000 seconds = milliseconds ÷ 1000

DigitsExampleRead asResult (UTC)
101760000000seconds2025-10-09T08:53:20Z
131760000000000milliseconds2025-10-09T08:53:20Z
11 to 12999999999999seconds, because it is below 1e12year 33658, almost always a mistake
161760000000000000millisecondstens of thousands of years later

The cut-off explains a strange result you may have seen: an eleven- or twelve-digit value is still read as seconds, because it is below 1e12, and it resolves to a date thousands of years ahead. If the answer lands in year 5138 or year 33658, the input was probably microseconds that lost three digits, or a millisecond value missing a digit.

Only numbers greater than zero are accepted. 0 is the epoch itself but is rejected by the same check that rejects -1, so enter 1 to inspect the first second of 1970. Decimals are allowed: 1760000000.5 becomes 1760000000500 milliseconds and keeps the half second.

3. Local time and UTC in the output

Each conversion prints two renderings of the same instant. The first is local, produced with toLocaleString('zh-CN', {hour12:false}), so it follows the time zone of the machine and uses a 24-hour clock. The second is toISOString(), which is always UTC, always ends in Z and always shows three fraction digits, for example 2025-10-09T08:53:20.000Z.

Timestamp (s)UTCUTC+8UTC−5
01970-01-01 00:00:001970-01-01 08:00:001969-12-31 19:00:00
10000000002001-09-09 01:46:402001-09-09 09:46:402001-09-08 20:46:40
17000000002023-11-14 22:13:202023-11-15 06:13:202023-11-14 17:13:20
20000000002033-05-18 03:33:202033-05-18 11:33:202033-05-17 22:33:20
21474836472038-01-19 03:14:072038-01-19 11:14:072038-01-18 22:14:07

Reading the local and UTC columns side by side is the fastest way to spot a time-zone bug. A value eight hours ahead of the UTC column is being shown in China Standard Time, not in UTC. If a server log says 08:53 and the browser says 16:53, nothing is broken: the same instant simply carries a +8 offset.

The reverse direction is the common trap. A datetime-local field has no zone, so the browser treats what you type as local wall-clock time. 2026-01-01 08:00 entered in UTC+8 becomes 1767225600, which is 2026-01-01T00:00:00Z; the same typed value in London becomes 1767254400, eight hours later in absolute terms.

4. Leap seconds never appear

Unix time is defined by POSIX as a count of 86,400-second days, so it deliberately ignores leap seconds. UTC has inserted 27 of them since 1972, the most recent at the end of 2016, yet no Unix timestamp is ever 23:59:60. During a positive leap second the same timestamp is reused for two real seconds, so Unix time is not strictly monotonic across that event.

This only matters for astronomy, satellite tracking and time-distribution work. For logs, orders, tokens and scheduled jobs, the 27-second divergence accumulated over five decades is irrelevant, and pretending every day has exactly 86,400 seconds keeps the arithmetic reliable.

If you need UTC including leap seconds, you need a different time scale with a leap-second table, not a wider integer.

5. The 2038 boundary

A signed 32-bit integer tops out at 2,147,483,647. Read as Unix seconds, that is 2038-01-19T03:14:07Z. One second later the value wraps to −2,147,483,648 and a 32-bit clock jumps back to 1901. This converter is unaffected, because JavaScript dates are IEEE 754 doubles covering about ±8.64e15 milliseconds, roughly ±100 million days.

2^31 − 1 = 2147483647 s = 2038-01-19T03:14:07Z 2^31 = 2147483648 s = 2038-01-19T03:14:08Z, overflows signed 32-bit

LimitValueDate (UTC)What breaks
Signed 32-bit maximum21474836472038-01-19T03:14:07Z32-bit time_t and some embedded firmware
One second later21474836482038-01-19T03:14:08Zwraps to 1901 on a 32-bit clock
MySQL TIMESTAMP21474836472038-01-19T03:14:07Zlater values are refused unless the column is DATETIME
JavaScript date limit8.64e15 msyear 275760not a practical concern

The fix is not to shorten dates but to widen storage: 64-bit time_t, DATETIME instead of TIMESTAMP in MySQL, and epoch values held in 64-bit integers. If you maintain an old device or a legacy C library, test that boundary now rather than in January 2038.

Seconds stored in a signed 64-bit integer reach year 292 billion; the practical limit comes from the date library, not from the integer.

6. Rounding and display

Converting a timestamp to a date never rounds: a whole number of milliseconds is exact, and 0.5 seconds survives as 500 ms. The opposite direction does round, because the tool reports whole seconds. It divides milliseconds by 1000 and takes the floor, so 08:53:20.999 becomes 08:53:20, not 08:53:21.

seconds = ⌊milliseconds ÷ 1000⌋

Keep milliseconds when events inside one second must stay ordered. For billing, store milliseconds or a separate sequence number: truncating a payment at 23:59:59.999 to 23:59:59 can move it into the previous day and the previous accounting period.

Pasting a long list of values? The word counter on this site runs in the same browser tab, so you can measure a log excerpt without sending it anywhere.

7. A worked conversion

Take 1700000000 and reproduce it by hand. Divide by 86,400 to get whole days, keep the remainder, then turn the remainder into hours, minutes and seconds.

StepCalculationResult
Days since epoch1700000000 ÷ 86400 = 19675.925919675 days
Remainder0.9259 × 8640080000 seconds
Time of day80000 = 22 × 3600 + 13 × 60 + 2022:13:20
Dateepoch + 19675 days2023-11-14
Combined in UTCdate plus time2023-11-14T22:13:20Z
Rendered in UTC+8add 8 hours2023-11-15 06:13:20

The same arithmetic works for any value below 1e12. Above that, divide by 1000 first, because the converter reads the number as milliseconds.

Open the Timestamp Converter

Keep reading