ISO 8601 to Unix Timestamp Converter
ISO 8601 strings are human-readable but harder to compare or store than integers. Converting to Unix seconds gives you a single number you can sort, subtract, and index efficiently.
Example: 2024-01-31T12:00:00Z
| Input (ISO 8601) | 2024-01-31T12:00:00Z |
|---|---|
| Unix (seconds) | 1706702400 |
| Unix (milliseconds) | 1706702400000 |
| ISO 8601 (UTC) | 2024-01-31T12:00:00Z |
Common Pitfall
Note: If the ISO string lacks a timezone indicator (e.g. `2024-01-31T12:00:00` with no Z or offset), most parsers treat it as local time - which means the same string produces different timestamps on different machines. Always include a Z or explicit offset.
Code Examples
Python
from datetime import datetime
int(datetime.fromisoformat('2024-01-31T12:00:00+00:00').timestamp())
JavaScript
Math.floor(new Date('2024-01-31T12:00:00Z').getTime() / 1000)
PHP
strtotime('2024-01-31T12:00:00Z')
Java
Instant.parse("2024-01-31T12:00:00Z").getEpochSecond()
Go
t, _ := time.Parse(time.RFC3339, "2024-01-31T12:00:00Z") t.Unix()