Unix Timestamps and UTC
What the Unix epoch is, seconds vs milliseconds, and how timestamps relate to local time.
A Unix timestamp counts seconds (or milliseconds) since 1970-01-01 00:00:00 **UTC** — the epoch. It carries no time zone; one number is one instant worldwide. Local display depends on IANA rules. Logs, APIs, and databases use this format heavily.
Seconds vs milliseconds
- Unix seconds: 10 digits, e.g. 1700000000
- JavaScript Date: milliseconds, 13 digits
- Mixing them causes 1000× errors — a common bug
- Year 2038: 32-bit limits are largely solved on modern 64-bit systems
Relating to local time
Timestamp to local: software applies IANA zones. Local to timestamp: you need zone + DST, then UTC instant — same idea as UTC Basics. Users reading UTC logs can map to home time with the Convert.
Best practices
- Store/transmit UTC or timestamps; localize only in UI
- Never store ambiguous local strings without offset
- Document whether your API uses seconds or milliseconds
- Zone rules: What Is the IANA Time Zone Database in Guides