Timestamp Converter: Working with Unix and Human-Readable Dates
Understand Unix timestamps, how to convert between timestamp formats, common mistakes, and working with dates in JavaScript, Python, and command line.
Unix timestamps are the backbone of time-based data in software. Every API response, database record, and log file uses them. Understanding how to work with timestamps is essential for debugging and building time-aware applications.
What Is a Unix Timestamp?
A Unix timestamp is the number of seconds (or milliseconds) that have elapsed since January 1, 1970 00:00:00 UTC (the Unix epoch). It's a single integer representing a point in time.
1758316800 → September 19, 2026 00:00:00 UTC
Why use timestamps?
- Timezone-agnostic — UTC by default
- Compact — a single integer
- Fast to compare — just integer comparison
- Easy to store — fits in a single database column
Timestamp Precision
| Unit | Length | Example |
|------|--------|---------|
| Seconds | 10 digits | 1758316800 |
| Milliseconds | 13 digits | 1758316800000 |
| Microseconds | 16 digits | 1758316800000000 |
| Nanoseconds | 19 digits | 1758316800000000000 |
Most APIs return seconds. JavaScript's Date.now() returns milliseconds. Always check which format you're working with.
Convert Timestamps in Code
JavaScript
// Current timestamp (seconds)
const now = Math.floor(Date.now() / 1000);
// Timestamp to Date
const date = new Date(1758316800 * 1000);
console.log(date.toISOString());
// "2026-09-19T00:00:00.000Z"
// Date to timestamp
const timestamp = Math.floor(date.getTime() / 1000);
// Format for display
date.toLocaleDateString('en-US', {
year: 'numeric',
month: 'long',
day: 'numeric',
hour: '2-digit',
minute: '2-digit'
});
Python
from datetime import datetime, timezone
# Current timestamp
now = datetime.now(timezone.utc).timestamp()
# Timestamp to datetime
dt = datetime.fromtimestamp(1758316800, tz=timezone.utc)
print(dt.isoformat())
# Datetime to timestamp
timestamp = int(dt.timestamp())
Command Line
# Current timestamp
date +%s
# Timestamp to date
date -d @1758316800
# Date to timestamp
date -d "2026-09-19" +%s
# ISO format
date -u -d @1758316800 +%Y-%m-%dT%H:%M:%SZ
Common Timestamp Values
| Value | Date | Use Case |
|-------|------|----------|
| 0 | Jan 1, 1970 | Unix epoch |
| 1000000000 | Sep 9, 2001 | Billion seconds |
| 1234567890 | Feb 13, 2009 | Famous number |
| 2147483647 | Jan 19, 2038 | 32-bit max (Y2K38) |
Common Mistakes
-
Confusing seconds and milliseconds — JavaScript returns milliseconds, most APIs return seconds. Always check.
-
Timezone confusion — Unix timestamps are always UTC. Converting to local time requires knowing the timezone.
-
Y2K38 problem — 32-bit signed integers overflow on January 19, 2038. Use 64-bit integers or milliseconds.
-
String comparison — always convert timestamps to integers before comparing. String comparison of
"9" > "10"istrue. -
Null timestamps —
0is a valid timestamp (Jan 1, 1970), not "no time". Usenullfor unset.
Timestamp Formats in APIs
| Format | Example | Parser |
|--------|---------|--------|
| Unix seconds | 1758316800 | new Date(n * 1000) |
| Unix ms | 1758316800000 | new Date(n) |
| ISO 8601 | 2026-09-19T00:00:00Z | new Date(s) |
| RFC 2822 | Thu, 19 Sep 2026 00:00:00 +0000 | new Date(s) |
Best Practices
- Store as UTC — always store timestamps in UTC, convert to local only for display
- Use ISO 8601 for human-readable —
2026-09-19T00:00:00Zis unambiguous - Use milliseconds for JavaScript —
Date.now()returns milliseconds - Validate before converting — invalid timestamps cause silent failures
- Consider timezones for display — always show timezone with human-readable dates
Try It Now
Use our free Timestamp Converter to convert between Unix timestamps and human-readable dates instantly — with timezone support and current timestamp display.