What Is a Unix Timestamp (Epoch Time)? Converting to and from Dates, the 2038 Problem
Updated: November 6, 2026 · AracMerkezi
▶ Open Unix Timestamp Converter
A Unix timestamp (epoch time) is the number of seconds that have passed since January 1, 1970 at 00:00:00 UTC. Because it is a single number, it is very easy to store dates, compare them and move them between different systems; it is widely used in databases, APIs, log files and JWT tokens. This guide explains, with tested examples, how to convert a timestamp to a date by hand and in code, how to find the difference between two timestamps, and the 2038 limit.
Examples
| Timestamp | Equivalent (UTC) |
|---|---|
| 0 | January 1, 1970 00:00:00 |
| 1,000,000,000 | September 9, 2001 01:46:40 |
| 1,767,225,600 | January 1, 2026 00:00:00 |
| 1,800,000,000 | January 15, 2027 08:00:00 |
Seconds or milliseconds?
Classic Unix time is in seconds and is a 10-digit number (current values are about 1.7 billion). JavaScript’s Date.now() value, on the other hand, is in milliseconds and has 13 digits. If a value has 13 digits, it is usually milliseconds; you divide by 1000 to get seconds. Example: 1,800,000,000,000 milliseconds, divided by 1000, is 1,800,000,000 seconds.
Time zone
A timestamp is independent of time zone; it always counts relative to UTC. When converting to a date, you choose which time zone to display it in. Turkey is at UTC+3, so the same timestamp appears 3 hours ahead of UTC in local time: the value 1,800,000,000 is 08:00 in UTC and 11:00 in Turkey time. Someone reading the same moment in New York sees the same number too; only the clock text on the screen differs, so passing the number between systems prevents misunderstandings. For time zone differences, see the time zone guide.
Converting by hand: what date is 1,800,000,000?
A day is 86,400 seconds (24 × 60 × 60). Steps:
- Whole days: 1,800,000,000 / 86,400 = 20,833.33… so 20,833 days.
- Remaining seconds: 1,800,000,000 − 20,833 × 86,400 = 28,800 seconds = 8 hours.
- Adding 20,833 days to January 1, 1970 gives January 15, 2027; time 08:00:00 UTC.
Checking in the reverse direction: 20,833 × 86,400 = 1,799,971,200, and adding 28,800 gives exactly 1,800,000,000, so the division and remainder came out right. We confirmed the result in a terminal with date -u -d @1800000000: “Fri Jan 15 08:00:00 UTC 2027”.
Converting with code
We ran and tested the following; all give the same moment:
- Python:
datetime.fromtimestamp(1800000000, timezone.utc)returns 2027-01-15 08:00:00+00:00. - JavaScript:
new Date(1800000000 * 1000).toISOString()returns2027-01-15T08:00:00.000Z; JavaScript expects milliseconds, so you multiply by 1000. - Date to timestamp (JavaScript):
Math.floor(Date.UTC(2026, 0, 1) / 1000)returns1767225600. - Terminal:
date -u -d @1767225600returns January 1, 2026 00:00:00 UTC.
The Unix Timestamp Converter on our site converts in both directions.
The difference between two timestamps
The difference is found by subtraction. Let March 15, 2026 09:00 UTC = 1,773,565,200 and March 18, 2026 17:30 UTC = 1,773,855,000:
- Difference = 1,773,855,000 − 1,773,565,200 = 289,800 seconds.
- 289,800 / 86,400 = 3 days with 30,600 seconds left over (8.5 hours); that is 3 days 8 hours 30 minutes (80.5 hours in total).
- For 7 days later, add 7 × 86,400 = 604,800 seconds: 1,773,565,200 + 604,800 = 1,774,170,000, which is March 22, 2026 09:00 UTC.
For calendar-day and business-day differences, see the days between two dates guide. To add months and years, adding seconds is not enough, because months are not the same length.
The 2038 problem
In older systems the timestamp is stored in a 32-bit signed number. The largest value this number can take, 2,147,483,647, corresponds to January 19, 2038 03:14:07 UTC. After that date, overflow can occur in 32-bit systems; if the number wraps to a negative value, a date such as December 13, 1901 20:45:52 UTC appears. In systems that use unsigned 32-bit, the limit is 4,294,967,295, which is February 7, 2106 06:28:15 UTC. Modern systems use 64 bits, so they are not affected by this problem.
Example use in JWTs and logs
The iat (issued at) and exp (expiry) fields in JWT tokens are Unix time in seconds. If iat = 1,800,000,000 and the token is valid for 1 hour, exp = 1,800,000,000 + 3,600 = 1,800,003,600; that is January 15, 2027 09:00:00 UTC. A timestamp past the expiry moment means “expired.” In log files, sorting lines by timestamp causes fewer errors than parsing date strings.
Practical tips
- The difference of two timestamps is the number of seconds between them. 86,400 seconds equal one day.
- Storing dates in the database as UTC timestamps and converting to local time on screen is the safest approach.
- Leap seconds are not counted separately in Unix time.
- Moments before 1970 are shown with negative values: −86,400 is December 31, 1969 00:00:00 UTC.
- For future local-time appointments (for example, “always 09:00 local time”), time zone rules can change; in that case storing the time zone name as well may be safer.
- Where a human will read it, the ISO 8601 format (
2026-01-01T00:00:00Z) is preferred; where a machine will read it, a number is enough.
Common mistakes
- Mistaking milliseconds for seconds: if you convert a 13-digit value as seconds, the date comes out around year 59,000.
- Mistaking seconds for milliseconds: a 10-digit value lands in early January 1970.
- Mistaking local time for UTC; in Turkey you get a 3-hour difference.
- Using
new Date(ts)in JavaScript and forgetting to multiply seconds by 1000. - Adding a fixed 30 × 86,400 seconds to add a month.
Glossary
- Epoch: The moment counting began (January 1, 1970 00:00:00 UTC).
- UTC: Coordinated Universal Time; the reference for time zones.
- ISO 8601: The international standard in which date and time are written in year-month-day order.
- Overflow: A number not fitting in the space where it is stored and wrapping around.
You can use the Unix Timestamp Converter tool for conversion. To calculate the day difference between two dates, see the Date Difference Calculator; for the exp field in a JWT, see the JWT guide.
Frequently asked questions
What does a Unix timestamp count?
The seconds that have passed since January 1, 1970 00:00:00 UTC.
What is a 13-digit timestamp?
It is usually in milliseconds; divide by 1000 to convert to seconds.
What is the 2038 problem?
The overflow of a 32-bit signed timestamp at 03:14:07 UTC on January 19, 2038; modern systems that use 64 bits are not affected.
Tools mentioned in this guide
More guides
- How to Calculate Age From a Date of Birth: Age in Years, Months and Days – Work out your exact age in years, months and days, step by step. Month-end and leap-day edge cases, total days lived and common mistakes.
- How to Calculate Days and Business Days Between Two Dates: Step by Step – How many days and business days lie between two dates? End-day rule, the full-week shortcut, leap years and the Excel difference, with worked examples.
- How to Write a Cron Expression: Crontab Scheduling Guide with Examples and Common Traps – What is a cron expression? Examples for every 5 minutes, 03:00 and weekdays at 09:30, plus the */7 trap, the day OR rule and time zone pitfalls.
- How Many Days Old Are You? A Guide to Calculating Days, Weeks and Months Since Birth – How many days, weeks and months since your birth date? Your 10,000th day, the leap year rule, days remaining and finding the day of the week.
- What Is a JWT (JSON Web Token) and How Does It Work? Decoding, Signature and Security – What is a JWT, how do you decode it and verify its signature? A real sample token, exp time math, a tampering test and security mistakes.
This article is for general information only and is not legal, financial or medical advice. We are not an official institution.