⏱️Developer

Unix Timestamps Explained: What They Are and How to Use Them

Unix timestamps appear in logs, APIs, and databases everywhere. Here's what they are, how to convert them, and common pitfalls to avoid.

4 min readFebruary 14, 2026By FreeToolKit TeamFree to read

Open a server log and you'll see numbers like 1740892800 everywhere. These are Unix timestamps — the count of seconds since January 1, 1970. Once you understand them, you can read any log, work with any API response that uses them, and avoid the common timezone bugs they help prevent.

Why Unix Timestamps Exist

A date like '3/15/26' is ambiguous — is that March 15 or the 15th day of the 3rd month in a 2-digit year? Is it in your timezone or the server's? Unix timestamps eliminate all of this: 1742054400 always means exactly the same moment for every computer on earth, regardless of timezone.

Converting Timestamps

Paste any Unix timestamp and see the human-readable date/time in any timezone. Or enter a date to see the Unix timestamp.

Millisecond vs Second Timestamps

JavaScript's Date.now() returns milliseconds since epoch (1740892800000 instead of 1740892800). Other languages (Python, Unix tools) use seconds. Divide JavaScript timestamps by 1000 to get seconds. Multiply seconds by 1000 to get milliseconds. Mixing these is a common source of bugs — a timestamp that's 1000× too large produces a date far in the future.

Getting the Current Timestamp

  • JavaScript: Math.floor(Date.now() / 1000) for seconds, Date.now() for milliseconds
  • Python: import time; int(time.time())
  • Bash: date +%s
  • SQL (PostgreSQL): EXTRACT(EPOCH FROM NOW())
  • PHP: time()

Debugging timestamps

When debugging a Unix timestamp you're not sure about, check the magnitude: 10 digits = seconds (year 2001–2286), 13 digits = milliseconds (year 2001–2286 too). If you get a weird date from a conversion, you probably mixed up seconds and milliseconds.

Frequently Asked Questions

What is a Unix timestamp?+
A Unix timestamp is the number of seconds elapsed since January 1, 1970, 00:00:00 UTC (the 'Unix epoch'). The current time in Unix is a large integer: around 1,740,000,000 in March 2026. This format is universal, timezone-agnostic, and easy to do arithmetic on. It's used in logs, databases, APIs, and operating systems. Milliseconds (ms) timestamps are the same concept multiplied by 1000 — used in JavaScript's Date.now().
What is the Year 2038 problem?+
On January 19, 2038, 32-bit signed integers representing Unix timestamps will overflow. A 32-bit signed integer maxes out at 2,147,483,647, which corresponds to 2038-01-19 03:14:07 UTC. Systems using 32-bit Unix timestamps will either overflow to negative numbers (representing dates in 1901) or crash. Modern 64-bit systems handle timestamps far past year 292 billion, so new systems aren't vulnerable. Legacy embedded systems and old databases using 32-bit timestamps need migration.
How do I convert a Unix timestamp to a readable date?+
JavaScript: new Date(timestamp * 1000).toISOString() (multiply by 1000 since JavaScript uses milliseconds). Python: datetime.fromtimestamp(timestamp) for local time, datetime.utcfromtimestamp(timestamp) for UTC. PHP: date('Y-m-d H:i:s', timestamp). SQL: FROM_UNIXTIME(timestamp) in MySQL, to_timestamp(timestamp) in PostgreSQL. Our Timestamp Converter handles any of these conversions without writing code.
Should I store timestamps as Unix integers or ISO strings in my database?+
Both work. Unix integers are compact (4–8 bytes), easy to do arithmetic on (adding seconds, comparing, sorting), and timezone-agnostic. ISO strings (2026-03-15T14:30:00Z) are human-readable, explicit about timezone, and easier to debug. PostgreSQL's TIMESTAMPTZ (timestamp with timezone) stores as UTC internally and converts to display timezone automatically — often the best option as it's both efficient and unambiguous. Use whatever your database's native datetime type is rather than storing in a generic integer column.

🔧 Free Tools Used in This Guide

FT

FreeToolKit Team

FreeToolKit Team

We build free browser-based tools and write practical guides that skip the fluff.

Tags:

developertimestampdatetimeunix