The Unix timestamp converter that tells you what you are looking at.
Code reference
Convert Unix epoch to date in any language
The tool above converts epoch ↔ date in your browser. The reference below shows how to do the same conversions in code, plus the lookup tables most often needed when working with Unix timestamps. Twenty languages and database engines; copy-and-paste ready.
Time interval reference
| Interval | Seconds |
|---|---|
| 1 minute | 60 |
| 1 hour | 3,600 |
| 1 day | 86,400 |
| 1 week | 604,800 |
| 1 month (~30.437 days, average) | 2,629,743 |
| 1 quarter (~91.31 days, average) | 7,889,229 |
| 1 year (365.25 days, Julian) | 31,557,600 |
| 1 decade | 315,576,000 |
Timestamp unit detection
The number of digits in a timestamp tells you which unit it's in. Epochr above auto-detects from the magnitude of the input.
| Digits | Unit | Range covered |
|---|---|---|
| 10 | Seconds | Sep 9, 2001 → Nov 20, 2286 |
| 13 | Milliseconds | Same range, in ms |
| 16 | Microseconds | Same range, in μs |
| 19 | Nanoseconds | Same range, in ns |
A 13-digit number that looks like seconds is almost certainly milliseconds. The most common silent bug in timestamp code is mixing the two.
Compiled languages
| Language | Get current epoch (seconds) | Convert epoch to date |
|---|---|---|
| C | time(NULL) | ctime(&epoch) |
| C++ (chrono) | std::chrono::duration_cast<std::chrono::seconds>(std::chrono::system_clock::now().time_since_epoch()).count() | std::ctime(&epoch) |
| Go | time.Now().Unix() | time.Unix(epoch, 0) |
| Rust | SystemTime::now().duration_since(UNIX_EPOCH).unwrap().as_secs() | chrono::DateTime::from_timestamp(epoch, 0).unwrap() |
| Java | System.currentTimeMillis() / 1000 | new java.util.Date(epoch * 1000) |
| Kotlin | System.currentTimeMillis() / 1000 | java.util.Date(epoch * 1000) |
| Swift | Int(Date().timeIntervalSince1970) | Date(timeIntervalSince1970: TimeInterval(epoch)) |
| C# / .NET | DateTimeOffset.UtcNow.ToUnixTimeSeconds() | DateTimeOffset.FromUnixTimeSeconds(epoch).UtcDateTime |
Scripting languages
| Language | Get current epoch (seconds) | Convert epoch to date |
|---|---|---|
| Python | int(time.time()) | datetime.fromtimestamp(epoch, tz=timezone.utc) |
| Ruby | Time.now.to_i | Time.at(epoch).utc |
| Perl | time | gmtime(epoch) |
| PHP | time() | gmdate('c', epoch) |
| Lua | os.time() | os.date('!%c', epoch) |
| Bash (Linux, GNU date) | date +%s | date -u -d @epoch |
| Bash (macOS, BSD date) | date +%s | date -u -r epoch |
| PowerShell | [DateTimeOffset]::UtcNow.ToUnixTimeSeconds() | [DateTimeOffset]::FromUnixTimeSeconds(epoch).UtcDateTime |
JavaScript / TypeScript
// Current epoch (seconds — drop the floor for milliseconds)
Math.floor(Date.now() / 1000)
// Convert epoch (seconds) to Date
new Date(epoch * 1000)
// Format as ISO 8601 UTC
new Date(epoch * 1000).toISOString()
// Format in user's local timezone
new Date(epoch * 1000).toLocaleString()
// Convert ISO date string to epoch seconds
Math.floor(new Date('2026-01-01T00:00:00Z').getTime() / 1000)Date.now() returns milliseconds. Divide by 1000 for seconds. The Math.floor matters when you need an integer to pass to a backend that expects seconds.
Databases
| Engine | Get current epoch (seconds) | Convert epoch to timestamp |
|---|---|---|
| PostgreSQL | EXTRACT(EPOCH FROM NOW())::BIGINT | TO_TIMESTAMP(epoch) |
| MySQL | UNIX_TIMESTAMP() | FROM_UNIXTIME(epoch) |
| SQL Server | DATEDIFF_BIG(SECOND, '1970-01-01', SYSUTCDATETIME()) | DATEADD(SECOND, epoch, '1970-01-01') |
| SQLite | unixepoch() | datetime(epoch, 'unixepoch') |
| Oracle | (SYSDATE - DATE'1970-01-01') * 86400 | TIMESTAMP '1970-01-01 00:00:00 UTC' + NUMTODSINTERVAL(epoch, 'SECOND') |
| MongoDB | Math.floor(Date.now() / 1000) | new Date(epoch * 1000) |
For SQL Server pre-2016, replace DATEDIFF_BIG with DATEDIFF (returns INT — overflows for very large differences).
Spreadsheets
| Application | Convert epoch (seconds) in cell A1 to date |
|---|---|
| Excel / LibreOffice Calc | =(A1 / 86400) + DATE(1970, 1, 1) |
| Google Sheets | =A1/86400 + DATE(1970, 1, 1) |
Format the result cell as Date/Time. Result is in UTC. For local time, add or subtract the timezone offset in seconds: =((A1 + 3600*(-5)) / 86400) + DATE(1970, 1, 1) for US Eastern Standard Time (UTC-5).
Common pitfalls and fixes
| Symptom | Cause | Fix |
|---|---|---|
| Date is off by ~50 years | Mixed seconds and milliseconds (treated 1.7B ms as 1.7B s) | Divide ms by 1000, or use a 13-digit-aware parser |
| Date is off by exactly N hours | Local time vs UTC mismatch | Use UTC explicitly: Python datetime.fromtimestamp(e, tz=timezone.utc), JS toISOString(), etc. |
| Year shows 1900 | C tm_year field is years since 1900 | Add 1900 to tm_year before display |
| Year shows 1970 / Jan 1 | Null or zero epoch | Validate input is non-zero before conversion |
| Epoch shifts by a few seconds vs reality | UTC vs TAI (leap seconds not counted) | Most languages skip leap seconds; this is normally correct, not a bug |
| Dates after Jan 19, 2038 wrap negative | Signed 32-bit time_t overflow (Y2K38) | Use 64-bit time_t (default on most modern systems) or store epoch in milliseconds |
| Date(1234567890) shows year 1970 in JS | JS Date constructor expects milliseconds, not seconds | Multiply by 1000: new Date(1234567890 * 1000) |
| time.time() returns a float in Python | Python returns sub-second precision by default | Wrap in int() if you need integer seconds |
Date formatting reference
Most-used format strings across languages:
| Format | strftime / Python / Ruby / PHP / Bash | JavaScript Intl |
|---|---|---|
| ISO 8601 (2026-05-12T14:30:00Z) | %Y-%m-%dT%H:%M:%SZ | .toISOString() |
| RFC 2822 (Tue, 12 May 2026 14:30:00 GMT) | %a, %d %b %Y %H:%M:%S GMT | .toUTCString() |
| US short (05/12/2026) | %m/%d/%Y | .toLocaleDateString('en-US') |
| EU short (12/05/2026) | %d/%m/%Y | .toLocaleDateString('en-GB') |
| Long form (Tuesday, May 12, 2026) | %A, %B %d, %Y | .toLocaleDateString('en-US', { dateStyle: 'full' }) |
Related concepts
- Year 2038 problem. Signed 32-bit Unix timestamps overflow on 2038-01-19 03:14:07 UTC. Most modern systems use 64-bit, but embedded systems and older databases may still be vulnerable.
- POSIX time vs TAI. Unix time deliberately excludes leap seconds. TAI (International Atomic Time) counts every second since 1958-01-01 and is currently 37 seconds ahead of UTC.
- ISO 8601. The international standard for date representation. Format YYYY-MM-DDTHH:MM:SS±HH:MM (or Z for UTC). Sortable as a string. Recommended over RFC 2822 for new systems.
- Timezone names vs offsets. An offset like -05:00 is unambiguous at a moment but doesn't tell you the timezone (which DST rules apply). A name like America/New_York tracks the rules across history.