What a millisecond timestamp is
A millisecond timestamp is the number of milliseconds since 00:00:00 UTC on 1 January 1970. It is the Unix timestamp multiplied by 1000, so it has 13 digits for any date between September 2001 and November 2286. JavaScript, Java, many databases and message systems use it because it keeps the time of an event to a thousandth of a second.
1700000000000 ms = 1700000000 seconds = 2023-11-14T22:13:20.000Z
To convert by hand, divide by 1000 to get seconds, then convert the seconds. The part after the division, the remainder, is the milliseconds: 1700000000123 is the same second plus 123 ms, shown as 22:13:20.123.
Where milliseconds come from
- JavaScript:
Date.now(),new Date().getTime()andperformance.timeOrigin. - Java and Kotlin:
System.currentTimeMillis(),Instant.toEpochMilli(). - Elasticsearch dates with the
epoch_millisformat, Kafka record timestamps, MongoDB and many REST APIs. - Mobile apps and analytics: Android
System.currentTimeMillis()and most event trackers.
Check the unit before you trust the date
| You have | Read as milliseconds it gives | Read as seconds it gives |
|---|---|---|
1700000000000 (13 digits) | 14 Nov 2023, correct | A date tens of thousands of years ahead |
1700000000 (10 digits) | 20 Jan 1970, probably wrong | 14 Nov 2023, correct |
A 10-digit result from this page that lands in January 1970 almost always means the number is in seconds. The page shows a warning in that case. Use the timestamp to date page, where the unit is detected automatically.
Microseconds and nanoseconds
Some systems record even finer time. Divide a 16-digit value (microseconds) by 1000, or a 19-digit value (nanoseconds) by 1,000,000, to get milliseconds. You can also choose those units in the Unit box. Dates are shown to the millisecond.
Convert milliseconds to a date in code
// JavaScript
new Date(1700000000000).toISOString(); // "2023-11-14T22:13:20.000Z"
// Java
Instant.ofEpochMilli(1700000000000L);
# Python (divide by 1000)
from datetime import datetime, timezone
datetime.fromtimestamp(1700000000000 / 1000, tz=timezone.utc)
// PHP
gmdate('Y-m-d H:i:s', intdiv(1700000000000, 1000));
// C#
DateTimeOffset.FromUnixTimeMilliseconds(1700000000000);
// Go
time.UnixMilli(1700000000000).UTC()
-- MySQL
SELECT FROM_UNIXTIME(1700000000000 / 1000);
-- PostgreSQL
SELECT to_timestamp(1700000000000 / 1000.0);
JavaScript limits
A JavaScript Date holds at most 8,640,000,000,000,000 ms either side of 1970, which is about 275,760 years. Beyond that, new Date(x) gives Invalid Date. This page reports an error for such values instead of a wrong date.
Date to milliseconds
For the other direction use date to timestamp, which shows the milliseconds next to the seconds. To get the current value, see the current Unix timestamp page. The full background is in What is Unix time?