A Unix timestamp in milliseconds is the number of milliseconds since 1970-01-01T00:00:00Z. It is the native time unit in JavaScript: Date.now() and Date.prototype.getTime() both return milliseconds, which is why millisecond timestamps appear constantly in web logs, API responses, database records, and front-end code. This converter decodes those values into readable dates and encodes dates back into milliseconds, all locally.
How it works
JavaScript’s Date constructor takes milliseconds directly, so decoding is straightforward:
const date = new Date(epochMilliseconds);
date.toISOString(); // UTC ISO-8601, e.g. "2023-11-14T22:13:20.000Z"
date.toString(); // Local time in your browser's timezone
To encode a date-time back to milliseconds, the tool parses the input string and reads .getTime() — no manual scaling needed. Both conversions run entirely in your browser using the built-in Date API.
A present-day millisecond timestamp is about 13 digits (for example 1700000000000). If your value is only about 10 digits it is in seconds and will decode to a date roughly 50 years in the future if treated as milliseconds. Check the digit count first.
The 10-digit vs 13-digit trap
This is by far the most common mistake with Unix timestamps. The confusion arises because older Unix tools, many databases, and shell utilities (date +%s) all work in seconds, while JavaScript, Java, and many modern APIs default to milliseconds.
| Value | Digits | Unit | What it represents |
|---|---|---|---|
1700000000 | 10 | seconds | 2023-11-14 (correct) |
1700000000000 | 13 | milliseconds | 2023-11-14 (correct) |
1700000000 treated as ms | 10 | wrong unit | 1970-01-20 (off by ~53 years) |
If you paste a 10-digit value and the decoded date is in January 1970, you have a seconds timestamp. Use the seconds converter for that case.
Where millisecond timestamps appear in practice
- JavaScript APIs —
Date.now(),performance.now()(relative),setTimeout, most event timestamps - Database columns — MongoDB’s
ObjectIdencodes creation time; many SQL schemas storeBIGINTepoch-ms - Log files — structured loggers (Winston, Pino, etc.) emit ISO strings or epoch-ms by default
- REST APIs — payment webhooks, analytics events, and auth tokens often use epoch-ms in JSON payloads
- Browser storage —
localStoragevalues representing expiry or creation times
Tips and edge cases
- The three trailing digits in a millisecond timestamp encode the sub-second portion (0–999 ms). If you only care about the second-level precision, you can truncate with
Math.floor(ms / 1000). - Negative values are valid and represent dates before 1 January 1970 — for example
-86400000is 31 December 1969 in UTC. - Always store and transmit the UTC ISO-8601 string for serialisation; use the local time representation only for display in a user’s timezone.