A Unix timestamp is the number of seconds since midnight UTC on 1 January 1970, the Unix epoch. It is a single number with no time zone, so computers use it to store, sort and compare moments in time, and APIs, databases and log files are full of them. This converter turns one into a date you can read, and turns a date back into a timestamp.
Current Unix timestamp
----------
Timestamp to date
Unit
Read as seconds (detected from the number of digits).
- UTC
- Tue 14 Nov 2023, 22:13:20 UTC
- Local time
- Working it out…
- ISO 8601
- 2023-11-14T22:13:20.000Z
- Relative
- Working it out…
Date to timestamp
Time zone
Reading the date as UTC. A time zone written in the date, such as +01:00, wins.
- Seconds
- 1700000000
- Milliseconds
- 1700000000000
- Microseconds
- 1700000000000000
Converted in your browser. Nothing you type is uploaded or stored.
The clock at the top ticks every second and copies in seconds or milliseconds.
Paste a timestamp under Timestamp to date and it is read as seconds,
milliseconds or microseconds, worked out from the number of digits. To convert
the other way, type a date such as 2023-11-14 22:13:20 under Date to
timestamp. Now fills either box with the current moment.
How to use it
- Paste a timestamp, or press Now. The UTC time, your local time, the ISO 8601 string and how long ago it was appear below.
- Check the line that says which unit it was Read as. If a small number came out in the wrong unit, choose Seconds, Milliseconds or Microseconds yourself.
- To go the other way, type a date. Leave the time off for midnight, or add
seconds, a fraction of a second, or a zone such as
Zor+01:00. - Choose whether a date with no zone in it is UTC or My time zone.
- Tap Copy next to any result.
Seconds, milliseconds or microseconds
The same moment is a different-sized number depending on the unit. This is the single biggest reason a timestamp "converts to the wrong year".
| Unit | Digits today | 14 Nov 2023, 22:13:20 UTC | Where it turns up |
|---|---|---|---|
| Seconds | 10 | 1700000000 | Unix date +%s, PHP time(), JWT exp and iat, Python time.time() |
| Milliseconds | 13 | 1700000000000 | JavaScript Date.now(), Java System.currentTimeMillis() |
| Microseconds | 16 | 1700000000000000 | Python datetime, PostgreSQL, many log pipelines |
A timestamp that is 1,000 times too big or too small is the usual symptom of a unit mix-up: a date tens of thousands of years away, or one in January 1970.
The converter detects the unit from the digits in the whole part of the number:
| Digits | Read as | Covers |
|---|---|---|
| Up to 11 | Seconds | 1970 to the year 5138 |
| 12 to 14 | Milliseconds | March 1973 to the year 5138 |
| 15 to 17 | Microseconds | March 1973 onward |
That means a millisecond timestamp from before March 1973, which has fewer than 12 digits, is read as seconds. Pick Milliseconds to override it. A 19-digit number is most likely nanoseconds, which this tool reads as an error and not as a date tens of thousands of years away.
Dates before 1970
A negative timestamp is a moment before the epoch. -1 is 23:59:59 UTC on 31
December 1969, and -14182940 is 20:17:40 UTC on 20 July 1969, the Apollo 11
landing. Type a minus sign in the box, or a date such as 1969-07-20 20:17:40
in the other. Both directions work, and the unit buttons apply to negative
numbers too.
The Year 2038 problem
Systems that keep the timestamp in a signed 32-bit integer run out of room at
2147483647, which is 03:14:07 UTC on 19 January 2038. One second later the
number wraps to -2147483648, which reads as 20:45:52 UTC on 13 December 1901.
Paste either value above to see it.
Nearly all current software uses 64-bit timestamps, which are good for about 292 billion years. The risk is in old embedded devices, file formats and database columns that store a 32-bit integer. If you maintain one, check the column type now rather than in 2037. An unsigned 32-bit timestamp lasts until 6:28:15 UTC on 7 February 2106.
Common gotchas
- Seconds against milliseconds.
Date.now()in JavaScript is milliseconds,time.time()in Python is seconds with a fraction. Divide by 1,000 or multiply, and name the unit in your field names:expires_at_ms. - Time zones are for display only. A timestamp has no zone. Store the number
or an ISO 8601 string with
Z, and convert to local time only when showing it to a person. - A date with no zone is ambiguous.
2023-11-14 22:13:20is a different moment in London and in Tokyo. The converter reads it as UTC unless you pick My time zone, and aZor+01:00in the text overrides both. - Daylight saving. A local time that the clocks skip is moved forward, and
one that happens twice is read as the first time round, which is what
JavaScript's
Datedoes. - Leap seconds are not counted. Every day is 86,400 seconds in Unix time.
- Precision. A JavaScript
Dateholds whole milliseconds, so a microsecond timestamp is shown to the millisecond and the digits beyond that are cut off.
Getting the current timestamp in code
| Language | Seconds | Milliseconds |
|---|---|---|
| JavaScript | Math.floor(Date.now() / 1000) | Date.now() |
| Python | int(time.time()) | int(time.time() * 1000) |
| Go | time.Now().Unix() | time.Now().UnixMilli() |
| Java | Instant.now().getEpochSecond() | System.currentTimeMillis() |
| C# | DateTimeOffset.UtcNow.ToUnixTimeSeconds() | DateTimeOffset.UtcNow.ToUnixTimeMilliseconds() |
| PHP | time() | (int) (microtime(true) * 1000) |
| Ruby | Time.now.to_i | (Time.now.to_f * 1000).to_i |
| Bash | date +%s | date +%s%3N |
| SQL (PostgreSQL) | floor(extract(epoch from now()))::bigint | floor(extract(epoch from now()) * 1000)::bigint |
Related
- The JavaScript cheat sheet for
Date, and the Python cheat sheet for thetimeanddatetimemodules. - Cron Expression Generator to turn "every weekday at 9" into a schedule and see its next run times in your time zone.
- UUID Generator: a version 7 UUID starts with a millisecond timestamp, and the checker there shows the date it holds.
- JSON Formatter to read an API response
before you convert the timestamps in it, and Base64 Encoder and
Decoder for the segments of a JWT, whose
expandiatfields are Unix timestamps.
Common questions
What is a Unix timestamp?
A Unix timestamp, also called epoch time or Unix time, is the number of seconds that have passed since 00:00:00 UTC on 1 January 1970, the Unix epoch. It is one plain number with no time zone in it, which is why systems use it to store and compare moments in time. 1700000000 is 14 November 2023 at 22:13:20 UTC.
How do I convert a Unix timestamp to a date?
Paste the timestamp into the box at the top of this page. It shows the date in UTC, in your own time zone and as ISO 8601, plus how long ago it was or how far away it is. In code, new Date(seconds * 1000) does it in JavaScript and datetime.fromtimestamp(seconds, timezone.utc) in Python.
How can I tell if a timestamp is in seconds or milliseconds?
Count the digits. Today's timestamps in seconds have 10 digits, in milliseconds 13 and in microseconds 16. This converter does that for you: up to 11 digits is read as seconds, 12 to 14 as milliseconds and 15 to 17 as microseconds. If a small number from early 1970 is read in the wrong unit, pick the unit yourself with the buttons under the box.
What is the Year 2038 problem?
Many older systems store the timestamp as a signed 32-bit integer, whose largest value, 2147483647, is 03:14:07 UTC on 19 January 2038. One second later the number overflows and wraps to -2147483648, which reads as 13 December 1901. Software that uses 64-bit timestamps, which is nearly all modern software, is not affected for about 292 billion years.
Can a Unix timestamp be negative?
Yes. A negative timestamp is a moment before 1 January 1970. -1 is one second before the epoch, 23:59:59 UTC on 31 December 1969, and -14182940 is the Apollo 11 landing in July 1969. This converter reads negative timestamps and dates before 1970 in both directions.
Does a Unix timestamp have a time zone?
No. A timestamp names one instant everywhere on Earth, and the time zone only matters when you turn it into a date for a person to read. The same timestamp is 22:13 in London and 17:13 in New York. That is why the converter shows UTC and your local time side by side, and why the date to timestamp direction asks which zone you mean.
Does a Unix timestamp count leap seconds?
No. Unix time treats every day as exactly 86,400 seconds, so a leap second repeats or smears a second instead of adding one to the count. That keeps date arithmetic simple, and it is why a timestamp is not quite the number of real seconds since 1970.
Is anything I enter here sent to a server?
No. The conversion runs in your browser and nothing you type is submitted anywhere. The site records that the tool was used, which direction and which unit, so we know which tools are worth building next. The timestamp or date itself is never part of that.