Epoch Timestamp To Date
Convert an epoch / Unix timestamp into a human readable date and vice-versa. Displays the current epoch time in seconds, milliseconds and microseconds.
Epoch and Unix timestamps explained
What is the Unix epoch?
The Unix epoch is the instant January 1, 1970 at 00:00:00 UTC. A Unix timestamp is the number of seconds elapsed since that instant, not counting leap seconds.
Seconds, milliseconds, microseconds or nanoseconds?
JavaScript's Date.now() and most JSON APIs return milliseconds (13 digits). A timestamp in the wrong unit is off by a factor of 1,000.
The year 2038 problem
Systems that store the timestamp as a signed 32-bit integer can only count up to 2,147,483,647 seconds, which corresponds to 2038-01-19 03:14:07 UTC. Modern systems use 64-bit integers.
How to get the current epoch time
| Language | Seconds | Milliseconds |
|---|---|---|
| JavaScript | Math.floor(Date.now() / 1000) |
Date.now() |
| Python | import time; int(time.time()) |
time.time_ns() // 1_000_000 |
| PHP | time() |
(int) round(microtime(true) * 1000) |
| Java | Instant.now().getEpochSecond() |
System.currentTimeMillis() |
| Bash | date +%s |
date +%s%3N |