← Back to Blog

What is a Unix Timestamp? Complete Guide for Developers

What is a Unix Timestamp?

A Unix timestamp (also called Epoch time, POSIX time, or Unix time) is a system for describing points in time. It represents the number of seconds that have elapsed since January 1, 1970, at 00:00:00 UTC.

The Unix Epoch

The starting point, January 1, 1970, 00:00:00 UTC, is called the Unix epoch. This date was chosen when Unix was being developed at Bell Labs in the early 1970s.

``

Epoch: January 1, 1970, 00:00:00 UTC

Timestamp: 0

Current example:

January 1, 2025, 00:00:00 UTC

Timestamp: 1735689600

`

Why Use Unix Timestamps?

1. Universal Standard

Unix timestamps are the same regardless of time zone. The value 1735689600 means the same moment in time whether you're in New York or Tokyo.

2. Easy to Store

A single integer is much simpler to store and index than formatted date strings:

`

// Timestamp: 10 characters

1735689600

// ISO String: 24 characters

2025-01-01T00:00:00.000Z

`

3. Easy to Compare

Comparing two timestamps is a simple integer comparison:

`javascript

if (timestamp1 > timestamp2) {

// timestamp1 is later

}

`

4. Easy to Calculate

Adding or subtracting time is straightforward:

`javascript

const oneHourLater = timestamp + 3600; // Add 1 hour

const oneDayAgo = timestamp - 86400; // Subtract 1 day

`

Seconds vs Milliseconds

Different systems use different precisions:

Unix Timestamps (Seconds)

  • Standard Unix/POSIX systems
  • Most database timestamps
  • 10 digits for current dates
  • Example: 1735689600

JavaScript Timestamps (Milliseconds)

  • JavaScript Date.now()
  • Many web APIs
  • 13 digits for current dates
  • Example: 1735689600000

`javascript

// JavaScript uses milliseconds

const msTimestamp = Date.now(); // 1735689600000

const secTimestamp = Math.floor(Date.now() / 1000); // 1735689600

`

Converting Timestamps

To Human-Readable Date

`javascript

const timestamp = 1735689600;

const date = new Date(timestamp * 1000);

console.log(date.toISOString());

// "2025-01-01T00:00:00.000Z"

`

From Date to Timestamp

`javascript

const date = new Date('2025-01-01T00:00:00Z');

const timestamp = Math.floor(date.getTime() / 1000);

// 1735689600

``

Common Timestamp Values

| Event | Timestamp |

|-------|-----------|

| Unix Epoch | 0 |

| Year 2000 | 946684800 |

| Year 2025 | 1735689600 |

| 32-bit Overflow | 2147483647 |

Limitations

The traditional 32-bit signed integer can only represent dates up to January 19, 2038. This is known as the Year 2038 problem. Modern systems use 64-bit integers to avoid this limitation.

Try TimestampSpark

Convert Unix timestamps to dates and back instantly with our free online tool.

Convert Timestamps Now