Guide · 4 min read
Unix Timestamp Converter: Epoch to Date
Decode Unix timestamps to dates and encode dates back to epoch: seconds vs milliseconds, UTC vs local time, with JS, Python, PHP and SQL examples.
Last updated: 2026-10-07
Tools for this guide
The short answer
A Unix timestamp counts seconds since 1970-01-01 00:00:00 UTC. Ten digits means seconds, thirteen means milliseconds — divide the long form by 1000 to get the classic form.
To convert either way without writing code, paste the value into the Timestamp Generator: it auto-detects seconds versus milliseconds and shows both the UTC and your local time, and it encodes dates back to epoch just as easily.
Decode a timestamp in three steps
First, count the digits: 10 means seconds, 13 means milliseconds, anything else is probably a different unit or a typo worth double-checking against the source.
Second, paste the digits into the Timestamp Generator and read the UTC line — UTC is the trustworthy reference for logs, databases and anything shared across timezones.
Third, glance at the local-time line to confirm what a human in your seat would have seen. When UTC and local straddle midnight, that split explains most off-by-one-day confusion.
Seconds versus milliseconds
Unix tradition counts whole seconds; JavaScript, Java and most web APIs count milliseconds. The two differ by exactly three trailing zeros, so conversion is one multiplication or division — never a timezone shift or a calendar lookup.
Mixed pipelines are where bugs breed: a frontend sending milliseconds into an endpoint that expects seconds lands dates in the year 50000+. When a decoded date looks absurd, check the digit count before suspecting anything else.
UTC versus local time
The timestamp itself has no timezone — it is a single instant on one global clock. Timezones only enter when software renders that instant as a date and wall-clock time for humans.
Keep one rule and most bugs vanish: store, transmit and compare epoch numbers, and convert to local strings at the last possible moment, on the display side. Daylight-saving transitions then become a formatting detail instead of a data corruption vector.
Encode a date back to epoch
Pick the calendar date in the Timestamp Generator and read off the epoch seconds or milliseconds for config files, API parameters and scheduled jobs. The minute-precision picker covers the overwhelmingly common cases.
When you need exact seconds — a cron boundary, a token expiry — set the minutes, then append the seconds in code. Millisecond output simply extends the same value with three zeros.
Code snippets: JavaScript, Python, PHP and SQL
JavaScript: Math.floor(Date.now() / 1000) yields current epoch seconds; Date.now() alone gives milliseconds. Python: int(time.time()) after importing time. PHP: time() returns seconds directly with no arguments.
SQL dialects differ: MySQL offers UNIX_TIMESTAMP() and FROM_UNIXTIME() as a matched pair, while PostgreSQL uses EXTRACT(EPOCH FROM NOW()) going out and TO_TIMESTAMP() coming back. All of them speak UTC epoch values, so results paste straight into the converter for verification.
Notes for browsers, servers and logs
In browser devtools, decode API responses in the console with new Date(value * 1000) for seconds or new Date(value) for milliseconds, then cross-check anything surprising in the Timestamp Generator before blaming the backend.
In server logs, prefer logging the raw epoch alongside any human string: the number sorts, diffs and survives timezone misconfiguration, while the pretty string is what operators actually read at 3 a.m. Both beat either alone.
Frequently asked questions
Why does JavaScript give me 13 digits?
Date.now() returns milliseconds, the web's native unit. Divide by 1000 and round down for classic 10-digit epoch seconds: Math.floor(Date.now() / 1000). APIs built on Unix conventions usually expect the 10-digit form.
Is the epoch the same in every timezone?
Yes. A timestamp counts seconds since 1970-01-01 00:00:00 UTC no matter where you stand — only the displayed date and clock time shift with the zone. Store and compare the number; convert to local time only for display.
What is the 2038 problem?
Systems that store timestamps in a signed 32-bit integer overflow on 2038-01-19. Modern stacks use 64-bit integers or millisecond floats and are unaffected. If you maintain legacy embedded code or old databases, that date is your audit deadline — not a reason to avoid epoch time today.
How do I handle timestamps with decimals?
Fractional values like 1728000000.5 carry sub-second precision most tools ignore. Round or floor to a whole number before pasting it here: the decoder expects plain digits, and the half-second almost never matters outside high-frequency logging.
Try it now — free, no signup
Unix time ↔ human time. Files stay on your device.
Open Timestamp Tool
