🗓️ How to Convert a Unix Timestamp to a Date

Turn seconds-since-1970 into a readable date

You've probably seen a number like 1735689600 sitting where a date should be in a server log or an API response. This article covers what a Unix timestamp actually is and why it's used, why mixing up seconds and milliseconds is such a common source of bugs, and how to convert one to a real date.

What a Unix Timestamp Is

A Unix timestamp (also called Unix time or POSIX time) is a single integer representing the number of seconds that have elapsed since 00:00:00 UTC on January 1, 1970 — a reference point known as the Unix epoch. For example, 1735689600 means exactly 1,735,689,600 seconds have passed since the epoch. Because a date is represented as one number instead of a "year-month-day hour:minute:second" string, it's trivial to store, compare, and sort. Figuring out which of two events happened first is just comparing two integers, and finding records within a date range is a single inequality. Most importantly, a Unix timestamp is an absolute point in time anchored to UTC, so there's no need to store timezone information alongside it. Whether the server is in Seoul or New York, the same instant is represented by the same number — you only convert to the viewer's local timezone when displaying it. That's why timestamps are the de facto standard for handling time inside databases, log files, and API responses.

Why Seconds vs. Milliseconds Trips People Up

One of the most common mistakes in practice is confusing second-based and millisecond-based timestamps. The original definition of a Unix timestamp is in seconds — Linux's date +%s, PHP's time(), and most Unix-style APIs all return an integer number of seconds. JavaScript, on the other hand, is the odd one out: Date.now() and new Date().getTime() both return milliseconds. You can tell the two apart by digit count. As of the current era, a second-based timestamp has 10 digits (e.g. 1783929600), while a millisecond-based one has 13 (e.g. 1783929600000). Feed a second-based value straight into JavaScript's new Date() without converting, and you'll get a nonsensical date near January 1970; mistake a millisecond value for seconds and multiply it by 1000, and you'll land tens of thousands of years in the future. Whenever you're integrating an API or parsing logs, get in the habit of checking the digit count first.

A Worked Conversion Example

Take the second-based timestamp 1735689600. Converted, it's January 1, 2025, 00:00:00 UTC. To express the same instant in milliseconds, multiply by 1000 to get 1735689600000. Going the other direction — from a date back to a timestamp — you again need to be clear on whether you're working in UTC or a local timezone, or the resulting number will be off. Instead of doing this arithmetic by hand, it's much faster to use a tool that auto-detects seconds vs. milliseconds from the digit count and converts to a date, and converts a picked date straight back into a timestamp.

Working with Unix timestamps by language

Common idioms for getting the current Unix time (in seconds) and converting a timestamp back to a date across popular languages and environments.

Language / envCurrent time (seconds)Timestamp → date
JavaScriptMath.floor(Date.now()/1000)new Date(ts*1000)
Pythonint(time.time())datetime.fromtimestamp(ts)
PHPtime()date('Y-m-d H:i:s', $ts)
JavaInstant.now().getEpochSecond()Instant.ofEpochSecond(ts)
MySQLUNIX_TIMESTAMP()FROM_UNIXTIME(ts)
Bashdate +%sdate -d @ts

Timestamps worth remembering

TimestampUTC timeMeaning
01970-01-01 00:00:00Start of the Unix epoch
1,000,000,0002001-09-09 01:46:40One billion seconds
2,000,000,0002033-05-18 03:33:20Two billion seconds
2,147,483,6472038-01-19 03:14:0732-bit signed integer limit (the Y2038 problem)
4,294,967,2952106-02-07 06:28:1532-bit unsigned integer limit

The UTC times above assume a seconds-based timestamp. In environments that use milliseconds (13 digits, e.g. JavaScript Date.now()), multiply or divide by 1000 to convert.

🗓️ Try it yourself with the tool

How to Convert a Unix Timestamp to a Date — Turn seconds-since-1970 into a readable date

More Guides

🔁
How to Find a Domain's IP Address
Find the real server IP a domain points to
🛰️
How to Check DNS Propagation (What Is TTL?)
Understand TTL and check propagation after a nameserver change
📡
The Easiest Way to Find Your IP Address
Public vs private IP, and how to check yours
📐
CIDR Notation and How to Calculate a Subnet Mask
Convert CIDR notation like /24 into a subnet mask
🩺
How to Check an SSL Certificate's Expiration Date
Check a certificate's expiry without opening a browser
🪪
Understanding JWT Structure and How to Decode It
The Header, Payload & Signature — explained
🗝️
How to Create an Apache .htpasswd File for Basic Auth
Generate an APR1-MD5 hashed .htpasswd file
🔑
What Makes a Strong Password (and How to Generate One)
Length, character sets & entropy explained
🔐
What Is Base64 Encoding and When to Use It
Why it's used in email attachments & data URIs
📘
Using a JSON Formatter to Read API Responses
Turn minified JSON into something readable
🗃️
How to Format Messy SQL Queries
Break a one-line SQL statement into readable clauses
🎨
Converting Between HEX, RGB, and HSL Color Codes
The difference between the three formats
🔠
camelCase, snake_case & Other Naming Conventions
When to use each naming style
🆚
How to Compare Two Text Files (Diff Checker)
Quickly spot differences between two versions