A Unix timestamp is the number of seconds since 00:00:00 UTC on January 1, 1970, and you convert it by translating that count into a human date in your chosen time zone. For example, 1700000000 becomes November 14, 2023, 22:13:20 UTC. Unix time is used in databases, logs, APIs, analytics tools, servers, and almost every system that needs a compact way to store time. The standard starting point is called the Unix epoch [source: Wikipedia].
TLDR: Unix time is a single number that stores a date and time as seconds since January 1, 1970, at midnight UTC. To convert it, use a programming language, spreadsheet formula, terminal command, or online converter. For example, a backend developer checking 50,000 login events might convert 1717200000 to see that those events started on June 1, 2024, 00:00:00 UTC. If 18% of failed logins happened in one hour, converting the timestamps makes the pattern obvious fast.
What Is a Unix Timestamp?
A Unix timestamp, also called Unix time, is a numeric way to represent time. Instead of storing “March 5, 2025, 2:30 PM,” a system stores something like 1741185000. That number is easier for computers to sort, compare, add, subtract, and store.
The whole idea is simple:
- 0 means January 1, 1970, 00:00:00 UTC.
- 60 means 60 seconds after that moment.
- 3600 means one hour after the epoch.
- 86400 means one full day after the epoch.
This makes date math much cleaner. Want to know if one event happened after another? Compare the numbers. Want to add one day? Add 86400. Want to find the gap between two actions? Subtract one timestamp from the other.
Why Unix Time Is So Common
Unix timestamps are everywhere because they are portable. A server in Tokyo, a database in Virginia, and a mobile phone in Berlin can all store the same timestamp. The local display can change later.
That matters more than people expect. Honestly, it feels like half of “date bugs” come from mixing local time, daylight saving time, and unclear formats like 03/04/2025. Is that March 4 or April 3? A timestamp avoids that mess.
Unix time is useful for:
- Application logs that need exact event order.
- API responses that pass time between systems.
- Databases that store creation and update times.
- Analytics that group activity by minute, hour, or day.
- Security audits that trace logins and suspicious access.
Seconds vs Milliseconds: The Annoying Part
The catch is that Unix timestamps do not always use seconds. Some systems use milliseconds. Others use microseconds or nanoseconds. This is where things get irritating fast.
A timestamp in seconds usually has 10 digits today, like this:
1717200000
A timestamp in milliseconds usually has 13 digits, like this:
1717200000000
If your converted date lands thousands of years in the future, you probably treated milliseconds as seconds. If it lands in 1970, you may have treated seconds as milliseconds. It drives me crazy that some APIs label the field time and make you guess the unit. That tiny omission can cost 10 minutes of debugging for no good reason.
How to Convert Unix Time Manually
Manual conversion is possible, but not fun for large numbers. The basic formula is:
Unix timestamp = seconds since 1970-01-01 00:00:00 UTC
So if you have:
86400
That means:
1970-01-01 00:00:00 UTC + 86400 seconds = 1970-01-02 00:00:00 UTC
For real timestamps, use software. Manual math gets boring and error-prone, especially when time zones enter the picture.
Convert Unix Time in JavaScript
JavaScript uses milliseconds in its Date object. That means you must multiply a seconds-based Unix timestamp by 1000.
const unixSeconds = 1717200000;
const date = new Date(unixSeconds * 1000);
console.log(date.toUTCString());
// Sat, 01 Jun 2024 00:00:00 GMT
If your timestamp is already in milliseconds, do not multiply it:
const unixMilliseconds = 1717200000000;
const date = new Date(unixMilliseconds);
console.log(date.toISOString());
// 2024-06-01T00:00:00.000Z
Convert Unix Time in Python
Python makes this clean with the datetime module.
from datetime import datetime, timezone
unix_time = 1717200000
date = datetime.fromtimestamp(unix_time, tz=timezone.utc)
print(date)
# 2024-06-01 00:00:00+00:00
To get the current Unix timestamp:
import time
print(int(time.time()))
That returns the current number of seconds since the epoch.
Convert Unix Time in Excel or Google Sheets
Spreadsheets count dates differently, so you need a formula. If your Unix timestamp is in cell A1, use:
=A1/86400 + DATE(1970,1,1)
Then format the cell as a date and time.
Why divide by 86400? Because spreadsheets often count time in days, while Unix time counts in seconds. There are 86,400 seconds in a day.
If your timestamp is in milliseconds, use:
=A1/1000/86400 + DATE(1970,1,1)
Convert Unix Time in the Command Line
On many Linux systems, you can use the date command:
date -d @1717200000 -u
Output:
Sat Jun 1 00:00:00 UTC 2024
On macOS, the syntax is different:
date -r 1717200000 -u
That mismatch is small, but it is still annoying. You copy a command from a Linux server, paste it into a Mac terminal, and suddenly it fails. Expect to waste a few seconds checking which version of date you are using.
How to Convert a Date Back to Unix Time
Conversion works both ways. You can turn a readable date into a Unix timestamp.
In JavaScript:
const date = new Date("2024-06-01T00:00:00Z");
const unixSeconds = Math.floor(date.getTime() / 1000);
console.log(unixSeconds);
// 1717200000
In Python:
from datetime import datetime, timezone
date = datetime(2024, 6, 1, 0, 0, 0, tzinfo=timezone.utc)
print(int(date.timestamp()))
# 1717200000
Time Zones: UTC First, Local Time Second
A Unix timestamp does not store a time zone. It represents one moment in time, usually interpreted from UTC. Your software then displays that moment in a local time zone.
For example, 1717200000 is:
- 2024-06-01 00:00:00 UTC
- 2024-05-31 20:00:00 in New York during daylight saving time
- 2024-06-01 09:00:00 in Tokyo
The timestamp is identical. The display changes. This is why logs should usually be stored in UTC. Convert to local time only when showing the value to a person.
Common Unix Timestamp Mistakes
- Mixing seconds and milliseconds. Check the digit count first.
- Forgetting UTC. A timestamp is not “your local time” by default.
- Parsing vague dates. Use ISO format like
2024-06-01T00:00:00Z. - Ignoring daylight saving time. Local clock changes can shift displayed hours.
- Storing formatted strings too early. Keep timestamps numeric when possible.
Best Practices for Working With Unix Time
Use UTC for storage. Use local time for display. Label your units clearly with names like created_at_seconds or expires_at_ms. If you control an API, document whether the timestamp is in seconds or milliseconds.
Also, prefer ISO 8601 strings when humans need to read the value. A number like 1735689600 is great for machines, but most people cannot read it without help. A value like 2025-01-01T00:00:00Z is much clearer.
Unix timestamps are simple once you know the rule: count seconds from the Unix epoch, convert in UTC, then display in the needed time zone. Most confusion comes from milliseconds, local time, and poorly documented tools. Handle those three carefully, and Unix time becomes one of the cleanest ways to work with dates.
