Epoch Converter
Convert Unix timestamps to readable dates and back, in seconds, milliseconds, microseconds or nanoseconds.
Current Unix epoch time
Timestamp to date
Date to timestamp
Start and end of a day, month or year
| Epoch (s) | Epoch (ms) |
|---|
Seconds to days, hours and minutes
Batch converter
A date without a time counts as midnight UTC. A date with a time and no offset counts as local time.
How to get the current epoch time
The first line returns the current Unix time in seconds. The second line converts the timestamp 1700000000 to a date. Click a snippet to copy.
JavaScript
Math.floor(Date.now() / 1000)
new Date(1700000000 * 1000).toISOString()
Python
import time; int(time.time())
from datetime import datetime, timezone datetime.fromtimestamp(1700000000, tz=timezone.utc)
PHP
time()
gmdate('Y-m-d H:i:s', 1700000000)Java
java.time.Instant.now().getEpochSecond()
java.time.Instant.ofEpochSecond(1700000000)
C#
DateTimeOffset.UtcNow.ToUnixTimeSeconds()
DateTimeOffset.FromUnixTimeSeconds(1700000000).UtcDateTime
Go
time.Now().Unix()
time.Unix(1700000000, 0).UTC()
Ruby
Time.now.to_i
Time.at(1700000000).utc
Rust
std::time::SystemTime::now()
.duration_since(std::time::UNIX_EPOCH)
.unwrap()
.as_secs()// with the chrono crate chrono::DateTime::from_timestamp(1700000000, 0)
Swift
Int(Date().timeIntervalSince1970)
Date(timeIntervalSince1970: 1700000000)
Kotlin
java.time.Instant.now().epochSecond
java.time.Instant.ofEpochSecond(1700000000)
Bash (date)
date +%s
date -u -d @1700000000 # GNU / Linux date -u -r 1700000000 # macOS / BSD
PowerShell
[DateTimeOffset]::UtcNow.ToUnixTimeSeconds()
[DateTimeOffset]::FromUnixTimeSeconds(1700000000).UtcDateTime
MySQL
SELECT UNIX_TIMESTAMP();
SELECT FROM_UNIXTIME(1700000000); -- session time zone
PostgreSQL
SELECT floor(extract(epoch FROM now()))::bigint;
SELECT to_timestamp(1700000000);
SQLite
SELECT unixepoch(); -- SQLite 3.38+
SELECT strftime('%s', 'now');SELECT datetime(1700000000, 'unixepoch');
Excel / Google Sheets
=(NOW()-DATE(1970,1,1))*86400
=A1/86400+DATE(1970,1,1)
NOW() returns local time, so subtract the UTC offset in hours × 3600 for true Unix time. Format the second result as a date and time. The result is in UTC.
Common time spans in seconds
| Time span | Seconds |
|---|---|
| 1 minute | 60 |
| 1 hour | 3,600 |
| 1 day | 86,400 |
| 1 week | 604,800 |
| 1 month (30.44 days on average) | 2,629,746 |
| 1 year (365.2425 days on average) | 31,556,952 |
What Unix time is
Unix time counts the seconds since 00:00:00 UTC on 1 January 1970, a moment known as the Unix epoch. The number is the same everywhere on Earth at a given instant, because a time zone only changes how a timestamp is displayed. Dates before 1970 get negative values, so -1 is 23:59:59 UTC on 31 December 1969. Systems store the value in seconds (10 digits for current dates), milliseconds (13 digits, used by JavaScript and Java), microseconds (16 digits) or nanoseconds (19 digits, used by Go and several databases). The converter reads the digit count to pick the unit and names the assumed unit next to the result. Microsecond and nanosecond values keep every digit, because the page does the arithmetic with big integers.
The Year 2038 problem
Many older systems store Unix time as a signed 32-bit integer. The largest such value, 2147483647, falls on 19 January 2038 at 03:14:07 UTC. One second later the counter wraps to -2147483648, which reads as 13 December 1901. Modern operating systems, databases and languages use 64-bit timestamps, good for about 292 billion years. Embedded devices, old file formats and database columns typed as 32-bit integers still need checking before 2038.
Leap seconds
Unix time treats every day as exactly 86,400 seconds and ignores leap seconds. Since 1972, 27 leap seconds have been added to UTC to keep clocks in step with the rotation of the Earth. During a leap second a Unix clock repeats a second or, on systems using a leap smear, runs slightly slow for several hours. The difference between two timestamps across a leap second is therefore one second short of the real elapsed time. In 2022 the General Conference on Weights and Measures decided to stop adding leap seconds by 2035.
Time zones and daylight saving time
The local times on the page come from the time zone set in the browser, including historical daylight saving rules. Converting a date to a timestamp in local time uses the same rules. A local time inside a daylight saving gap, such as 02:30 on the night clocks move forward, does not exist. The converter moves the time forward by the size of the gap and shows a note. All conversions run in the browser, and no timestamp leaves the device.