Unix timestamp converter.
Convert an epoch timestamp to a human date, or a date to a timestamp. Seconds, milliseconds, microseconds and nanoseconds are detected automatically. Nothing leaves your browser.
Current Unix time...seconds
Milliseconds...what Date.now() returns
UTC...ISO 8601
About this tool
Unix time counts seconds since 00:00:00 UTC on 1 January 1970, ignoring leap seconds. Most systems log it in seconds; JavaScript, Java and many databases use milliseconds; some tracing and database systems use microseconds or nanoseconds. Paste any of them: the number of digits decides the unit (up to 10 is seconds, 13 is milliseconds, 16 is microseconds, 19 is nanoseconds) and the detected unit is shown in the output. Type a date on the right to go the other way. Link straight to a value with /tools/epoch?t=1700000000.
What you get back
| Row | Meaning |
|---|---|
| Seconds, milliseconds, microseconds, nanoseconds | The same instant in each unit, ready to paste into whatever expects it. |
| ISO 8601 | 2023-11-14T22:13:20.000Z. The format to use in APIs and logs; unambiguous and sortable. |
| RFC 1123 (UTC) | The HTTP date format used in Date, Expires and Last-Modified headers. |
| Local | The instant in your browser's time zone, with the zone name and UTC offset. |
| Relative | How long ago or how far ahead. The fastest sanity check on a token expiry or a log line. |
| Day of year, ISO week | For cron schedules and reports. |
Get the current Unix timestamp in code
| Language | Seconds | Milliseconds |
|---|---|---|
| Go | time.Now().Unix() | time.Now().UnixMilli() |
| JavaScript | Math.floor(Date.now() / 1000) | Date.now() |
| Python | int(time.time()) | int(time.time() * 1000) |
| PHP | time() | (int) (microtime(true) * 1000) |
| Java | Instant.now().getEpochSecond() | System.currentTimeMillis() |
| Rust | SystemTime::now().duration_since(UNIX_EPOCH)?.as_secs() | .as_millis() |
| C# | DateTimeOffset.UtcNow.ToUnixTimeSeconds() | DateTimeOffset.UtcNow.ToUnixTimeMilliseconds() |
| Ruby | Time.now.to_i | (Time.now.to_f * 1000).to_i |
| Shell | date +%s | date +%s%3N (GNU) |
| PostgreSQL | extract(epoch from now())::bigint | (extract(epoch from now()) * 1000)::bigint |
| MySQL | UNIX_TIMESTAMP() | ROUND(UNIX_TIMESTAMP(NOW(3)) * 1000) |
| SQLite | strftime('%s','now') | (julianday('now') - 2440587.5) * 86400000 |
Convert a timestamp to a date in code
| Language | From seconds |
|---|---|
| Go | time.Unix(1700000000, 0).UTC() |
| JavaScript | new Date(1700000000 * 1000).toISOString() |
| Python | datetime.fromtimestamp(1700000000, tz=timezone.utc) |
| PHP | gmdate('c', 1700000000) |
| Java | Instant.ofEpochSecond(1700000000) |
| Shell | date -u -d @1700000000 (GNU) · date -u -r 1700000000 (macOS) |
| PostgreSQL | to_timestamp(1700000000) |
| MySQL | FROM_UNIXTIME(1700000000) |
Things that go wrong with timestamps
- Seconds vs milliseconds: a 13-digit value fed to something expecting seconds becomes a date in the year 55,000 or so. The converter shows which it detected.
- Local time treated as UTC: a date string without a zone is interpreted differently by every library. Always include
Zor an offset. - The year 2038 problem: 32-bit signed seconds overflow at
2147483647(19 January 2038). Use 64-bit integers. - Leap seconds: Unix time pretends they do not exist, so a timestamp cannot represent 23:59:60. Almost nothing cares, but astronomers do.
- Negative values: dates before 1970 are negative timestamps and are perfectly valid.