ToolHubTools

Timestamp Converter

Convert between Unix timestamps and date-time, supporting seconds/milliseconds.

Current timestamp (refreshes every second)
Milliseconds (13-digit)
1789525713670
Seconds (10-digit)
1789525713
Beijing time: 2026-09-16 10:28:33
Timestamp → Date
Date → Timestamp (Beijing time)
Sponsored

Features

  • Timestamp to date: enter a timestamp to automatically display the corresponding time
  • Date to timestamp: select a date to get second/millisecond timestamps
  • Real-time display of current timestamp

FAQ

What is a Unix timestamp?

A Unix timestamp is the total number of seconds from January 1, 1970, 00:00:00 UTC (the Unix Epoch) to a specified time. It is a cross-platform, cross-timezone way of representing time, widely used in databases, APIs, and logging systems.

What is the difference between second and millisecond timestamps?

A second-level timestamp is a 10-digit number (e.g., 1700000000), while a millisecond-level timestamp is a 13-digit number (e.g., 1700000000000). JavaScript Date.now() returns milliseconds, while most backend languages (such as Python, PHP) default to seconds. This tool supports both.

What is the Year 2038 problem?

On 32-bit systems, the maximum value of a second-level Unix timestamp is 2147483647 (2^31-1), corresponding to January 19, 2038, 03:14:07 UTC. Exceeding this time causes an integer overflow. 64-bit systems are not affected, but legacy systems and embedded devices still need attention.

Why does the timestamp conversion result not match my local time?

The timestamp itself is in UTC. When converting to local time, the timezone must be considered. This tool defaults to displaying Beijing time (UTC+8). If you are in another timezone, please note the time difference. For example, Beijing time is 8 hours ahead of UTC.

How to get the current timestamp in different programming languages?

JavaScript: Date.now() (milliseconds), Python: time.time() (seconds), Java: System.currentTimeMillis() (milliseconds), Go: time.Now().Unix() (seconds), PHP: time() (seconds).

Can timestamps be negative?

Yes. Times before January 1, 1970 are represented as negative numbers. For example, the timestamp for December 31, 1969, 23:59:59 UTC is -1. This may be encountered when handling historical dates, but some systems do not support negative timestamps.

What is the difference between ISO 8601 and timestamps?

ISO 8601 is a date-time string format (e.g., 2024-01-01T00:00:00Z) that is human-readable but takes up more space. A timestamp is a pure number, convenient for calculation and comparison, but not human-readable. Both formats are common in APIs; timestamps are more suitable for storage and computation.

How to verify if a timestamp conversion is correct?

You can verify using known time points. For example, timestamp 0 corresponds to 1970-01-01 08:00:00 (Beijing time), and timestamp 1700000000 corresponds to 2023-11-14 22:13:20 (Beijing time). This tool real-time display feature can also help with verification.

About Timestamp Converter

Online Unix timestamp to date-time converter, supports second and millisecond timestamps, with automatic current timestamp display. This tool runs entirely in your browser. No data is uploaded to the server, helping protect your privacy. Everything works instantly with no software or plugin required.

Unix Timestamp Explained: Principles, Timezones, and Programming Practices

The Origin and Definition of Unix Timestamps

The Unix timestamp is the total number of seconds calculated from Coordinated Universal Time (UTC) January 1, 1970, 00:00:00, and this starting moment is called the "Unix Epoch." This design originated from the development of the Unix operating system in the 1970s, when developers needed a simple, unified way to represent time.

The greatest advantage of timestamps is timezone independence - it represents the same absolute moment anywhere in the world. Display differences across timezones are simply offsets added to or subtracted from the timestamp. This makes timestamps the ideal choice for database storage, API communication, and cross-timezone systems.

Second-level and Millisecond-level Timestamps

Traditional Unix timestamps have second-level precision, stored as 32-bit integers. But in scenarios requiring higher precision (such as JavaScript, Java), millisecond-level timestamps are used. The distinction is simple: 10 digits means seconds, 13 digits means milliseconds. In systems that mix different languages, this difference is a common source of bugs.

JavaScript Date.now() and Date.getTime() return millisecond timestamps. If you need seconds, you can convert with Math.floor(Date.now() / 1000). Conversely, converting seconds to milliseconds just requires multiplying by 1000. In API design, it is recommended to explicitly annotate the timestamp unit to avoid confusion.

The Relationship Between Timezones and Timestamps

Timestamps themselves have no timezone concept - they always represent UTC time. But when we convert a timestamp to human-readable date-time, we need to consider the timezone. For example, timestamp 1700000000 is 2023-11-14 22:13:20 in UTC, and 2023-11-15 06:13:20 in Beijing time (UTC+8).

A common mistake is treating local time directly as UTC time when calculating timestamps. The correct approach is to first convert local time to UTC, then calculate the timestamp. In JavaScript, the new Date() constructor automatically handles timezones, but toISOString() returns a UTC time string, while toLocaleString() returns a local time string.

The Year 2038 Problem (Y2038 Bug)

The maximum value of a 32-bit signed integer is 2,147,483,647, corresponding to UTC time January 19, 2038, 03:14:07. Beyond this moment, second-level timestamps on 32-bit systems will experience integer overflow, potentially causing system crashes or incorrect time calculations. This is the famous "Year 2038 problem."

The solution is to migrate to 64-bit timestamps. On modern 64-bit operating systems, time_t is already 64-bit, theoretically capable of representing time up to over 292 billion years. However, some legacy systems, embedded devices, and older databases still use 32-bit timestamps and need to be upgraded before 2038. For web applications, JavaScript uses 64-bit floating-point numbers to store timestamps and is not affected by this limitation.

Timestamps in Database Applications

MySQL TIMESTAMP type internally uses Unix timestamps, with a range of 1970-2038 (32-bit limitation). The DATETIME type directly stores date-time strings, with a larger range but no automatic timezone conversion. In distributed systems, it is recommended to use BIGINT to store millisecond timestamps, which is neither limited by 2038 nor convenient for cross-timezone calculations.

MongoDB _id field embeds a 4-byte timestamp (millisecond-level), from which the creation time can be extracted from the ObjectId. Redis TTL is also calculated based on timestamps. When designing database schemas, the best practice is to uniformly use UTC timestamps for storage and convert to user timezones at the presentation layer.

Timestamp Handling in Various Programming Languages

JavaScript/TypeScript: Date.now() returns a millisecond timestamp, and new Date(timestamp) can convert a timestamp to a Date object. Note that JavaScript timestamps are in milliseconds, unlike most backend languages which use seconds.

Python: time.time() returns floating-point seconds, datetime.datetime.fromtimestamp() can convert to a date object. Java: System.currentTimeMillis() returns milliseconds, Instant.ofEpochSecond() handles seconds. Go: time.Now().Unix() returns seconds, time.Now().UnixMilli() returns milliseconds. Go 1.17+ added UnixMilli() and UnixMicro() methods. Understanding the differences across languages is crucial for cross-language API development.

Sponsored