UnixTime / Reference
Unix timestamp milliseconds to date
Understand the difference between a 10-digit Unix timestamp and a 13-digit timestamp in milliseconds, with tested examples and practical code.
How to tell seconds and milliseconds apart
Unix time counts elapsed seconds from 1970-01-01 00:00:00 UTC. Some systems represent the same instant in a finer unit. Current timestamps often have 10 digits in seconds, 13 in milliseconds, 16 in microseconds and 19 in nanoseconds. This is a useful clue, not a universal rule: dates before 2001, negative values and far-future dates can have different lengths.
If a 13-digit value produces an impossibly distant date, you may have interpreted milliseconds as seconds. A reliable converter should let you choose the unit explicitly rather than relying solely on the number of digits.
One instant in four precisions
| Unit | Example | Calculation |
|---|---|---|
| Seconds | 1735689600 | Base Unix timestamp |
| Milliseconds | 1735689600000 | Seconds × 1,000 |
| Microseconds | 1735689600000000 | Seconds × 1,000,000 |
| Nanoseconds | 1735689600000000000 | Seconds × 1,000,000,000 |
All four numbers describe 2025-01-01 00:00:00 UTC. The zeros show the difference in unit; they do not mean the clock has become more accurate. An underlying reading may only be precise to seconds even if stored in a nanosecond-sized field.
Converting 13-digit Unix milliseconds in JavaScript
JavaScript's Date constructor expects milliseconds. The browser's Date.now() also returns milliseconds. To get Unix seconds, divide by 1,000 and use Math.floor. For dates before 1970, Math.floor and Math.trunc produce different results for fractional negatives.
const milliseconds = 1735689600000;
new Date(milliseconds).toISOString(); // "2025-01-01T00:00:00.000Z"
const seconds = Math.floor(milliseconds / 1000); // 1735689600
What about microseconds and nanoseconds?
Multiplying modern Unix seconds by a billion gives a number larger than JavaScript's maximum safe integer. Use BigInt for exact integer arithmetic, especially when milliseconds are not enough. Standard JavaScript Date still represents human-readable times at millisecond precision, so the remaining digits must be kept separately if your application needs them.
const epochNanoseconds = 1735689600000000001n;
const epochMilliseconds = epochNanoseconds / 1000000n;
const readable = new Date(Number(epochMilliseconds)).toISOString();
// "2025-01-01T00:00:00.000Z"
// The extra 1 nanosecond remains in epochNanoseconds.
Are timestamps affected by daylight saving time?
No. An epoch timestamp identifies an instant regardless of the viewer's time zone. A displayed date can change when you select Brussels, London or New York. Daylight-saving changes affect how local clock times map to instants, not the epoch timestamp for an already known instant.
Unix time excludes leap seconds and is not the same thing as a local wall clock. For logs, database exports and API responses, record the unit and whether the human-readable date was UTC.
Reference: MDN Date.now() reference.