CalquioCalquio

Search

Search for calculators and tools

Timestamp Converter

Convert Unix timestamps to human-readable dates and vice versa. Support seconds and milliseconds.

Code Examples
// Get current Unix timestamp (seconds)
const timestamp = Math.floor(Date.now() / 1000);
// Get current timestamp (milliseconds)
const timestampMs = Date.now();
// Convert timestamp to Date
const date = new Date(timestamp * 1000);
// Convert Date to timestamp
const ts = Math.floor(date.getTime() / 1000);

You May Also Like

What is a Unix Timestamp?

A Unix timestamp (also called Epoch time or POSIX time) is the number of seconds that have elapsed since January 1, 1970, 00:00:00 UTC - a moment known as the "Unix Epoch."

Right now, as you read this, the timestamp is a number like 1705312800.

Why January 1, 1970? When Unix was being developed in the early 1970s, the creators needed a starting point. They picked a recent, round date. The first Unix systems couldn't count very far back anyway!

Why does this matter to you?

  • Timestamps are language-agnostic - every programming language understands them
  • They're timezone-independent - always in UTC
  • Easy to compare and calculate time differences
  • Used everywhere: databases, APIs, log files, cookies

Timestamp Formats

FormatUnitExampleCommon Usage
Unix (seconds)Seconds1705312800Most APIs, databases
Unix (milliseconds)Milliseconds1705312800000JavaScript, Java
Unix (microseconds)Microseconds1705312800000000High-precision logs
Unix (nanoseconds)Nanoseconds1705312800000000000Go, system calls

Quick check: If the number is 10 digits, it's seconds. If it's 13 digits, it's milliseconds. JavaScript's Date.now() returns milliseconds!

Memorable Timestamps

๐ŸŽ‰ Unix Epoch Milestones

TimestampDateEvent
0Jan 1, 1970The beginning of Unix time
1000000000Sep 9, 2001First 10-digit timestamp
1234567890Feb 13, 2009"Epoch party" celebrated worldwide
1500000000Jul 14, 20171.5 billion seconds
2000000000May 18, 2033The next big milestone
2147483647Jan 19, 2038โš ๏ธ Y2K38 Problem

โš ๏ธ The Year 2038 Problem (Y2K38)

Many older systems store timestamps as a signed 32-bit integer, which maxes out at 2147483647 (January 19, 2038, 03:14:07 UTC).

After this moment, these systems will "overflow" and think it's December 13, 1901!

Most modern systems use 64-bit integers, which won't overflow for 292 billion years.

Timestamps and Timezones

The Beauty of UTC

Unix timestamps are always in UTC (Coordinated Universal Time). This solves the timezone headache:

Timestamp: 1705312800

= Jan 15, 2024 10:00:00 UTC
= Jan 15, 2024 05:00:00 EST (New York)
= Jan 15, 2024 19:00:00 JST (Tokyo)
= Jan 15, 2024 11:00:00 CET (Berlin)

Same number, different local times. When working with timestamps:

  1. Store everything as UTC timestamps
  2. Convert to local time only for display
  3. Accept user input in their timezone, convert to UTC immediately

Common mistake: Assuming a timestamp is in your local timezone. It's not - it's always UTC!

Practical Conversion Tips

Quick Mental Math

  • 1 day = 86,400 seconds
  • 1 week = 604,800 seconds
  • 1 month โ‰ˆ 2,592,000 seconds (30 days)
  • 1 year โ‰ˆ 31,536,000 seconds

Common Operations:

// Current timestamp
Math.floor(Date.now() / 1000)

// Add 1 day
timestamp + 86400

// Subtract 1 week
timestamp - 604800

// Start of today (UTC)
Math.floor(Date.now() / 86400000) * 86400

Debugging Timestamps:

When you see a suspicious timestamp:

  1. Check the digit count (10 = seconds, 13 = milliseconds)
  2. Use a converter to verify the date makes sense
  3. Check if it's negative (before 1970) or in the future

Timestamps in APIs

Common API Patterns:

// Twitter/X style (seconds)
{
  "created_at": 1705312800
}

// JavaScript style (milliseconds)
{
  "timestamp": 1705312800000
}

// ISO 8601 string (human-readable)
{
  "created_at": "2024-01-15T10:00:00Z"
}

Best Practices:

  • Always document whether you use seconds or milliseconds
  • Include timezone info or state "all times are UTC"
  • Use ISO 8601 strings for human-facing APIs
  • Use numeric timestamps for machine-to-machine communication

Fun Timestamp Facts

๐Ÿ“… Negative Timestamps Dates before 1970 are represented as negative numbers:

  • -1 = December 31, 1969, 23:59:59 UTC
  • -86400 = December 31, 1969, 00:00:00 UTC

๐ŸŽ‚ Your Birthday in Unix Time Born on March 15, 1990? Your timestamp is approximately 637,632,000!

โฐ New Year's Eve 1999 The Y2K bug was famously a non-event, but Unix systems weren't affected anyway - their "2000" was just another second tick to 946684800.

๐ŸŒ Leap Seconds Unix timestamps pretend leap seconds don't exist. When a leap second occurs, the timestamp repeats! This keeps timestamps predictable but slightly inaccurate astronomically.