Unix Timestamp Converter: What Is a Timestamp and How to Convert It

Tools 閲覧

What Is a Unix Timestamp?

A Unix timestamp is the number of seconds (or milliseconds) elapsed since January 1, 1970, 00:00:00 UTC — a reference point called the Unix Epoch.

For example: timestamp 1700000000 = November 14, 2023, 22:13:20 UTC.

Why use timestamps? They're timezone-independent absolute values — the same number everywhere in the world, making them ideal for storing, transmitting, and comparing times across systems.

How to Convert Timestamps Online

Use the tool.tl Timestamp Converter:

  1. Go to tool.tl/timestamp-converter
  2. Enter a timestamp and select the unit (seconds or milliseconds)
  3. See the corresponding UTC time and your local time instantly
  4. Or enter a date/time to get the Unix timestamp

Seconds vs Milliseconds vs Microseconds

PrecisionExample ValueDigit CountCommon In
Seconds (Unix time)1700000000~10 digitsLinux, databases, backend APIs
Milliseconds1700000000000~13 digitsJavaScript, Java, frontend logs
Microseconds1700000000000000~16 digitsHigh-precision logs, DB transactions

Quick identification rule: 10 digits = seconds, 13 digits = milliseconds, 16 digits = microseconds.

Getting the Current Timestamp in Code

# Python
import time
int(time.time())           # seconds:      1700000000
int(time.time() * 1000)   # milliseconds: 1700000000000

// JavaScript
Date.now()                 // milliseconds: 1700000000000
Math.floor(Date.now()/1000) // seconds:    1700000000
new Date().toISOString()   // "2023-11-14T22:13:20.000Z"

# Shell (Linux/Mac)
date +%s                   # seconds

-- MySQL
SELECT UNIX_TIMESTAMP();   -- seconds
SELECT NOW();              -- human-readable

-- PostgreSQL
SELECT extract(epoch FROM now())::bigint;  -- seconds

Timestamps and Time Zones

A Unix timestamp is always UTC — it contains no timezone information. Converting to local time requires adding or subtracting the timezone offset:

  • Timestamp 0 = 1970-01-01 00:00:00 UTC = 1970-01-01 08:00:00 CST (UTC+8)
  • The same timestamp shows a different clock time in each timezone, but it always represents the exact same moment

Key Timestamp Reference Points

Date/Time (UTC)Unix Timestamp
1970-01-01 00:00:00 (Epoch)0
2000-01-01 00:00:00946,684,800
2024-01-01 00:00:001,704,067,200
2038-01-19 03:14:07 (Y2K38 limit)2,147,483,647
The Year 2038 Problem: 32-bit signed integers storing Unix timestamps overflow at 2,147,483,647 on January 19, 2038. Modern systems use 64-bit integers (supporting dates ~292 billion years into the future). Check your older systems if they store timestamps as 32-bit integers.

Frequently Asked Questions

Can timestamps be negative?

Yes. Negative timestamps represent dates before January 1, 1970. For example, -86400 is December 31, 1969, 00:00:00 UTC. Most systems support negative timestamps for historical dates.

What's the difference between TIMESTAMP and DATETIME in MySQL?

TIMESTAMP stores as a Unix timestamp internally (range: 1970–2038, auto-converts to UTC). DATETIME stores the literal date/time string (range: 1000–9999, no Y2K38 issue). For new projects, prefer DATETIME or a BIGINT storing millisecond timestamps.

What's the ISO 8601 format and how does it relate to timestamps?

ISO 8601 (e.g., 2024-01-15T10:30:00Z) is a human-readable standardized time format. The trailing Z means UTC. It can be parsed into a Unix timestamp and vice versa — they represent the same moment, just in different formats. ISO 8601 is preferred for APIs and logs because it's both human-readable and unambiguous.