Unix Timestamp: Seconds vs Milliseconds

Quick guide · 3 min read

Quick Answer

10 digits = seconds. 13 digits = milliseconds. Milliseconds = seconds × 1000. JavaScript uses milliseconds; Python, PHP, and most databases use seconds. Use a timestamp converter to check any timestamp format.

What Is the Difference

Both formats count time from the Unix epoch (January 1, 1970, 00:00:00 UTC), but with different precision:

Example: January 1, 2024, 12:00:00 UTC

Seconds 1704110400
Milliseconds 1704110400000

The millisecond format is simply the seconds value multiplied by 1000. This gives millisecond precision, which is useful for measuring short durations or high-frequency events.

How to Tell: 10 vs 13 Digits

The easiest way to identify the format is by counting digits:

  • 10 digits = seconds (standard Unix timestamp)
  • 13 digits = milliseconds (JavaScript, Java, some databases)

For example:

  • 1704110400 (10 digits) = seconds
  • 1704110400000 (13 digits) = milliseconds

Timestamp Converter

Use our Timestamp Converter to check any timestamp instantly

Open Converter →

Common Mistakes

⚠️ Mistake 1: Using the wrong format

If you pass a millisecond timestamp to a system expecting seconds, you'll get a date far in the future (year 53000+). Always check which format your API or database expects.

⚠️ Mistake 2: JavaScript vs other languages

JavaScript's Date.getTime() returns milliseconds. Most other languages (Python, PHP, Ruby) use seconds. Remember to convert when passing timestamps between systems.

⚠️ Mistake 3: Database storage

Some databases store timestamps in seconds, others in milliseconds. Check your database documentation before inserting or querying timestamp values.

How to Convert Between Formats

Converting is straightforward:

  • Seconds to milliseconds: multiply by 1000
  • Milliseconds to seconds: divide by 1000 (or remove last 3 digits)

Example:

  • 1704110400 × 1000 = 1704110400000
  • 1704110400000 ÷ 1000 = 1704110400

Which Format Should You Use

Use seconds when:

  • Working with Unix/Linux systems
  • Storing in MySQL, PostgreSQL (integer columns)
  • Using Python, PHP, Ruby, Go

Use milliseconds when:

  • Working with JavaScript/Node.js
  • Measuring performance or short durations
  • Using Java's System.currentTimeMillis()

Need to Convert a Timestamp?

Our free Timestamp Converter handles both formats automatically

Try Converter →