O que e um timestamp Unix: segundos desde 1970 e o problema de 2038

8 min de leitura

Aprenda o que e Unix timestamp, como converter e o problema Y2K38.

What is a Unix timestamp and why it starts in 1970

A Unix timestamp (also called Unix epoch, POSIX time) is the number of seconds elapsed since January 1, 1970 at 00:00:00 UTC, known as the "Unix epoch."

Example: Timestamp 1742169600 = March 17, 2025 at 00:00:00 UTC.

Why 1970: Unix creators (Ritchie and Thompson at Bell Labs) needed a reference point. January 1, 1970 was recent, round, and convenient for 32-bit variables.

Right now: Current Unix timestamp is around 1,774,000,000.

Convert timestamps with the NexTools timestamp converter.

How to convert timestamps to dates and back

Timestamp → Date: 1742169600 → March 17, 2025, 00:00:00 UTC

Date → Timestamp: March 17, 2026 → 1773705600

JavaScript:

new Date(1742169600 * 1000).toISOString()
Math.floor(new Date("2026-03-17").getTime() / 1000)

Note the × 1000: JavaScript uses milliseconds (13 digits), not seconds (10). Most common error when working with timestamps in JS.

The NexTools converter handles both formats automatically.

The Year 2038 problem (Y2K38)

Unix timestamps in signed 32-bit integers max at 2,147,483,647 = January 19, 2038 at 03:14:07 UTC.

After that, overflow resets to -2,147,483,648 = December 13, 1901.

Affected: Embedded systems, 32-bit databases, legacy C code using 32-bit time_t.

Solution: Migrate to 64-bit timestamps. Linux kernel 5.6+ (2020) uses 64 bits. Most modern systems already support dates until year 292 billion.

Timestamps in milliseconds vs seconds

TypeDigitsExampleUsed by
Seconds101773705600Unix, PHP, Python, MySQL, PostgreSQL
Milliseconds131773705600000JavaScript, Java, modern REST APIs

Classic error: Passing milliseconds where seconds are expected (or vice versa). Result: dates in year 56,000 or 1970.

Calculate date differences with the date difference calculator.

Timestamps in databases and APIs

MySQL: UNIX_TIMESTAMP(), FROM_UNIXTIME(1773705600)

PostgreSQL: EXTRACT(EPOCH FROM NOW()). Supports microseconds and native timezones.

MongoDB: ObjectId includes 4-byte timestamp. ObjectId.getTimestamp().

REST APIs: Modern convention: ISO 8601 for public endpoints, numeric timestamps internally.

Timezones and timestamps: why UTC matters

Unix timestamps are ALWAYS UTC. No timezone. This is a huge advantage:

Problem with local dates: "March 17, 2026 at 2:00 PM" is ambiguous without timezone.

Timestamps solve this: 1773757200 is one unambiguous moment in time, anywhere on Earth.

Best practices: Store in UTC always. Convert to local only for display.

For timezone work, see the NexTools timezone converter.

Timestamps in different programming languages

JavaScript: Date.now() → ms. Math.floor(Date.now()/1000) → s.

Python: import time; time.time() → seconds with decimals.

PHP: time()

Java: System.currentTimeMillis() → ms.

Go: time.Now().Unix()

Ruby: Time.now.to_i

Bash: date +%s

The NexTools converter accepts both 10-digit and 13-digit timestamps.

Famous timestamps and their meaning

0 (Jan 1, 1970): The Unix epoch. Day zero of modern computing.

1000000000 (Sep 9, 2001): The billionth second. Celebrated globally.

1234567890 (Feb 13, 2009): Memorable sequence. Geek parties worldwide.

2000000000 (May 18, 2033): Next milestone. Not yet reached.

2147483647 (Jan 19, 2038): INT32 maximum. Y2K38.

Fun fact: If you see January 1, 1970 in an app, it's almost certainly a bug: some system interpreted 0 or null as a timestamp.

Experimente esta ferramenta:

Abrir ferramenta

Perguntas frequentes

Why is the Unix epoch January 1 1970

Chosen by Unix creators as a convenient reference. Recent, round date, and 32-bit integer range (±2.1 billion seconds) covered a useful span from 1901 to 2038.

What happens after 2038 with 32-bit timestamps

Counter overflows back to 1901 dates. Unupdated systems may fail. Solution: migrate to 64-bit, supporting dates until year 292 billion. Most modern systems already did.

What is the difference between seconds and milliseconds timestamps

Seconds: 10 digits. Milliseconds: 13 digits. JavaScript/Java use milliseconds. Unix/Python/PHP/SQL use seconds. Mixing them causes dates in year 56,000 or 1970.

Do timestamps have a timezone

No. Unix timestamps are always UTC. Same timestamp = same instant worldwide. Convert to local time only for display.

How do I convert a timestamp to a readable date

JavaScript: new Date(timestamp * 1000). Python: datetime.fromtimestamp(timestamp). Terminal: date -d @timestamp. Or use the NexTools converter.

Why do some apps show January 1 1970 as a date

Bug: system interpreted 0, null, or empty as Unix timestamp. Timestamp 0 = Jan 1, 1970 00:00:00 UTC.