🍋
Menu
How-To Beginner 2 min read 300 words

Epoch and Unix Timestamp Conversion Guide

Convert between Unix timestamps, ISO 8601 dates, and human-readable formats across timezones.

Key Takeaways

  • Unix timestamps — seconds since January 1, 1970 00:00:00 UTC — are the universal representation for points in time in computing.
  • Always store and transmit timestamps in UTC.
  • When converting a timestamp to a human-readable date, always specify the timezone: "March 1, 2024 19:00 EST" not just "March 1, 2024 19:00".
  • Always include the timezone offset.
  • ### Common Conversion Pitfalls Leap seconds: UTC has had 27 leap seconds since 1972, but Unix timestamps ignore them (a day is always 86,400 seconds).

Unix Timestamp Conversion

Unix timestamps — seconds since January 1, 1970 00:00:00 UTC — are the universal representation for points in time in computing. Converting between timestamps and human-readable dates requires careful timezone handling.

Timestamp Formats

Standard Unix timestamps are seconds since epoch (10 digits: 1709337600 = March 2, 2024 00:00:00 UTC). JavaScript and Java use milliseconds (13 digits: 1709337600000). Some systems use microseconds (16 digits) or nanoseconds (19 digits). When parsing an unknown timestamp, the digit count tells you the precision.

Timezone Handling

The single most common timestamp bug: treating a UTC timestamp as local time or vice versa. Always store and transmit timestamps in UTC. Convert to local time only for display. When converting a timestamp to a human-readable date, always specify the timezone: "March 1, 2024 19:00 EST" not just "March 1, 2024 19:00".

ISO 8601 Format

ISO 8601 is the standard string format: 2024-03-02T00:00:00Z (Z = UTC), 2024-03-01T19:00:00-05:00 (EST). Always include the timezone offset. The T separator between date and time is required. For date-only values, omit the time: 2024-03-02. This format sorts correctly as strings, which is why databases and APIs prefer it.

Common Conversion Pitfalls

Leap seconds: UTC has had 27 leap seconds since 1972, but Unix timestamps ignore them (a day is always 86,400 seconds). This means Unix timestamps are technically offset from TAI by 27 seconds. In practice, this rarely matters. The Year 2038 problem: 32-bit signed timestamps overflow on January 19, 2038. Use 64-bit timestamps in new systems.

Browser-Based Conversion

Client-side timestamp converters process entirely locally. Enter a Unix timestamp to see the human-readable date in UTC and your local timezone. Enter a date to get the Unix timestamp. Useful for debugging log entries, database records, and API responses where times are stored as numbers.

เครื่องมือที่เกี่ยวข้อง

รูปแบบที่เกี่ยวข้อง

คู่มือที่เกี่ยวข้อง