🕐 Epoch Converter
Convert between Unix timestamps and human-readable dates
What is Unix Time?
Unix time (also known as POSIX time or epoch time) is a system for describing a point in time. It is the number of seconds that have elapsed since the Unix epoch, which is 00:00:00 UTC on 1 January 1970.
Why January 1, 1970?
This date was chosen as a convenient reference point when Unix was being developed in the early 1970s. It was recent enough to be relevant but far enough in the past to avoid negative numbers for contemporary dates.
Format Variations
- Seconds: Standard Unix timestamp (e.g., 1723641420)
- Milliseconds: Common in JavaScript and web APIs (e.g., 1723641420000)
- Microseconds: Used in some databases and high-precision systems
- Nanoseconds: Used in Go and other systems requiring nanosecond precision
⚠️ Common Gotchas
Seconds vs Milliseconds
JavaScript uses milliseconds by default, while most other systems use seconds. Always check the documentation!
new Date(1723641420) // Wrong! Missing *1000
Y2K38 Problem
32-bit signed integers overflow on January 19, 2038. Use 64-bit timestamps for future dates.
timestamp > 2147483647 // Will overflow on 32-bit systems
Leap Seconds
Unix time ignores leap seconds, so it can be off by several seconds from atomic time.
Unix time: 86400 seconds/day (always)
Timezone Assumptions
Unix timestamps are always UTC. Never assume local timezone without explicit conversion.
new Date(timestamp) // Shows in local timezone!
✅ Best Practices
Always Store in UTC
Store timestamps in UTC and convert to local time only for display.
datetime.utcnow() // Python
Use Appropriate Data Types
Use 64-bit integers for timestamps to avoid Y2K38 problem.
BIGINT in SQL, int64 in Go, long in Java
Validate Ranges
Check for reasonable timestamp ranges in your application.
if timestamp < 0 or timestamp > 4102444800: raise ValueError
Handle Precision Consistently
Be explicit about whether you're using seconds, milliseconds, etc.
timestamp_ms = timestamp_s * 1000
🔗 Additional Resources
- Unix Time - Wikipedia
Comprehensive overview of Unix time
- Y2K38 Problem
Understanding the 32-bit timestamp overflow
- ISO 8601 Standard
International standard for date and time representation