All articles
·4 min read

What Is a Unix Timestamp and How Do You Convert It?

If you have ever looked at a database record and seen a column called created_at containing a number like 1719878400, you have encountered a Unix timestamp. This format appears in databases, APIs, log files, and programming languages across every platform. Understanding it saves time when debugging and makes reading raw data much easier.

What Is the Unix Epoch?

A Unix timestamp counts the number of seconds that have elapsed since January 1, 1970 at 00:00:00 Coordinated Universal Time (UTC). That starting point - second zero - is called the Unix epoch. The date was chosen in the early days of Unix development and has since become the universal computing standard for representing a specific moment in time.

For example, the timestamp 1719878400 represents July 2, 2024 at 00:00:00 UTC. You can verify this: 1,719,878,400 divided by 86,400 (seconds in a day) gives 19,906 days since January 1, 1970, which lands on that date.

Seconds vs Milliseconds - The Most Common Confusion

Traditional Unix timestamps count in seconds, producing a 10-digit number. JavaScript's Date.now() returns milliseconds, producing a 13-digit number. Many modern APIs and databases use milliseconds for finer precision. Always check which unit a system uses before doing arithmetic with timestamps.

A quick rule of thumb that works until the year 2286: if the timestamp has 10 digits, it is in seconds. If it has 13 digits, it is in milliseconds. Mixing them up - for example, passing milliseconds into a function that expects seconds - produces dates far in the future or past and is one of the most common timestamp bugs.

Why Timestamps Are Preferred Over Date Strings

  • Time zone neutrality - a Unix timestamp always represents UTC. There is no ambiguity about which time zone a date belongs to.
  • Easy arithmetic - subtract two timestamps to get an exact duration in seconds, with no calendar logic required.
  • Storage efficiency - an integer takes less space than a formatted date string.
  • Universal support - every programming language and database has built-in functions for working with Unix timestamps.
  • No formatting ambiguity - no confusion between DD/MM/YYYY and MM/DD/YYYY conventions.

The Year 2038 Problem

On older 32-bit systems, Unix timestamps are stored as a signed 32-bit integer, which can hold a maximum value of 2,147,483,647. That value corresponds to January 19, 2038 at 03:14:07 UTC. After that moment, a 32-bit timestamp counter would overflow and reset to a large negative number, representing a date in 1901. This is known as the Y2K38 problem. Modern 64-bit systems can store timestamps safely for hundreds of billions of years, but some legacy embedded systems remain at risk.

Quick check: is your timestamp 10 digits (seconds) or 13 digits (milliseconds)? Confusing the two is the most common source of timestamp bugs in applications.

Try it yourself - free

Use our Timestamp Converter - no account, no sign-up required.

Open Tool