If you've worked with APIs, databases, logs, authentication systems or backend applications, you've probably encountered a Unix timestamp.
You may see values such as:
1725369600
At first glance, it looks like a random number. It isn't. A Unix timestamp represents a specific point in time and is widely used by computers to store and exchange dates.
In this guide, we'll explain what a Unix timestamp is, how Unix time works, the difference between seconds and milliseconds, and how to convert timestamps in JavaScript, Python and Linux.
What is a Unix timestamp?
A Unix timestamp is the number of seconds that have elapsed since the Unix epoch.
The Unix epoch is:
January 1, 1970 at 00:00:00 UTC
For example:
0 = January 1, 1970 00:00:00 UTC
A larger timestamp represents a later point in time.
Unix timestamps are useful because computers can work with a single numeric value instead of storing dates in different human-readable formats.
Why do developers use Unix time?
Unix timestamps are common because they are simple to store, compare and transmit.
They are frequently used in:
• REST APIs
• Databases
• Application logs
• JWT tokens
• Authentication systems
• Cloud applications
• Cron jobs and scheduling
• File metadata
• Distributed systems
For example, comparing two timestamps is straightforward:
timestamp A < timestamp B
This means timestamp A occurred before timestamp B.
Unix timestamp seconds vs milliseconds
One of the most common timestamp mistakes is confusing seconds with milliseconds.
A Unix timestamp in seconds might look like:
1757894400
A timestamp in milliseconds might look like:
1757894400000
Milliseconds are 1,000 times larger because there are 1,000 milliseconds in one second.
In JavaScript, Date.now() returns milliseconds.
For example:
Date.now()
If you need Unix time in seconds, you can use:
Math.floor(Date.now() / 1000)
When working with an API, always check whether it expects seconds or milliseconds.
How to get the current Unix timestamp in JavaScript
JavaScript's Date object can be used to work with Unix time.
Current timestamp in milliseconds:
Date.now()
Convert it to seconds:
Math.floor(Date.now() / 1000)
You can also convert a Unix timestamp back into a JavaScript Date:
const timestamp = 1757894400;
const date = new Date(timestamp * 1000);
console.log(date);
How to convert Unix timestamps in Python
Python provides the time module for working with Unix timestamps.
Get the current Unix timestamp:
import time
print(int(time.time()))
Convert a timestamp into a readable UTC date:
from datetime import datetime, timezone
timestamp = 1757894400
date = datetime.fromtimestamp(timestamp, tz=timezone.utc)
print(date)
How to get Unix time on Linux
Linux systems make it easy to work with Unix timestamps from the command line.
To get the current timestamp:
date +%s
To convert a Unix timestamp into a readable date:
date -d @1757894400
On systems with GNU date, this is a convenient way to inspect timestamps while troubleshooting logs and scripts.
Common Unix timestamp mistakes
1. Seconds vs milliseconds
This is probably the most common mistake.
If an application expects seconds but receives milliseconds, the resulting date can be completely wrong.
2. Local time vs UTC
Unix timestamps represent an instant in time, while the human-readable representation can be displayed in different time zones.
When debugging APIs, logs or databases, check which timezone the application expects.
3. Treating a timestamp as a formatted date
A timestamp such as 1757894400 is not inherently a date string like 2025-09-15. It is a numeric representation of an instant in time.
4. Forgetting the unit
Always document whether a field contains seconds, milliseconds or another unit.
A quick way to convert Unix timestamps
When debugging an API response or checking a log, you don't always want to write a script just to convert one timestamp.
For quick conversions, you can use Devnary's browser-based Unix Timestamp Converter:
https://devnary.in/tools/timestamp-converter
It is useful when you need to convert Unix timestamps to readable dates or convert dates back to Unix time without installing another application.
For occasional debugging tasks, a small browser utility can be faster than opening a full development environment.
Unix timestamp cheat sheet
Unix epoch:
January 1, 1970 00:00:00 UTC
JavaScript milliseconds:
Date.now()
JavaScript seconds:
Math.floor(Date.now() / 1000)
Linux current timestamp:
date +%s
Python current timestamp:
int(time.time())
Important:
Seconds and milliseconds are different units. Always check the API or system documentation before converting.
Top comments (0)