Milliseconds to Date
Convert a 13-digit millisecond timestamp — the kind produced by
Date.now() and System.currentTimeMillis() — into a
readable date. The unit is preset to milliseconds so pasted values are never
misread as seconds.
Unix timestamp to date
Auto-detect reads the magnitude: 10 digits are seconds, 13 milliseconds, 16 microseconds, 19 nanoseconds.
| Your local time | — |
|---|---|
| Selected time zone | — |
| UTC / GMT | — |
| ISO 8601 | — |
| RFC 2822 | — |
| Relative | — |
| Day of week | — |
| Day of year / week | — |
Where 13-digit timestamps come from
Millisecond epochs dominate anything touched by JavaScript or the JVM:
Date.now()andnew Date().getTime()in JavaScriptSystem.currentTimeMillis()andInstant.toEpochMilli()in Java- Kafka record timestamps and most Elasticsearch date fields
- MongoDB
ISODatevalues when serialised to$date - Firebase, Stripe webhooks in some fields, and most browser performance APIs
Converting between units
| From | To | Operation |
|---|---|---|
| Milliseconds | Seconds | Math.floor(ms / 1000) |
| Seconds | Milliseconds | s * 1000 |
| Milliseconds | Microseconds | ms * 1000 |
| Nanoseconds | Milliseconds | Math.floor(ns / 1e6) — use BigInt |
Truncate rather than round when going from finer to coarser units. Rounding
1710050400999 to seconds gives 1710050401, one second
later than the instant actually described — enough to break an
expiry check or a signed request.
The BigInt boundary
Millisecond values are safe in a plain JavaScript number. Nanosecond values
are not: a 19-digit integer exceeds Number.MAX_SAFE_INTEGER
(about 9.007 × 1015), so the low digits get silently rounded away.
If you are handling Go UnixNano() output or Prometheus
timestamps in JavaScript, parse them with BigInt and only narrow
to a number after dividing down to milliseconds.
Related tools
Frequently asked questions
What is a 13-digit timestamp?
A 13-digit epoch value is milliseconds since 1 January 1970. It is what Date.now() returns in JavaScript and what System.currentTimeMillis() returns in Java, which is why it appears throughout web and JVM stacks.
How do I convert milliseconds to seconds?
Divide by 1000 and discard the remainder — Math.floor(ms / 1000). Do not round: rounding can push a timestamp into the next second and break ordering or signature checks that expect truncation.
Why does JavaScript use milliseconds when Unix uses seconds?
JavaScript's Date type was modelled on Java's, which chose millisecond resolution in 1995 as a compromise between range and precision for a 64-bit float. Unix time_t predates both and counts whole seconds. The mismatch at that boundary is the most common timestamp bug in web development.
Do I lose precision converting milliseconds to a JavaScript Date?
No. A JavaScript number is a 64-bit float with 53 bits of integer precision, which represents millisecond timestamps exactly for roughly ±285,000 years. Precision only becomes a problem with microsecond and nanosecond values, where 19-digit integers exceed what a float can hold exactly — use BigInt for those.