Convert a Unix timestamp by checking its unit first, then translating it from UTC into the date and time format your system or users expect. A Unix timestamp is a count of time since 00:00:00 UTC on 1 January 1970, usually measured in seconds, and that definition is widely used across operating systems, databases, APIs, logs, and programming languages [source: Wikipedia].
TLDR: A Unix timestamp such as 1700000000 means a specific UTC moment, not a formatted date by itself. To convert it, identify whether it is in seconds or milliseconds, then use a converter, command line tool, spreadsheet formula, or programming language date function. In a typical analytics export with 50,000 rows, mixing seconds and milliseconds can shift dates by decades, which can wreck reports in under a minute. For example, 1700000000 in seconds converts to 14 November 2023, 22:13:20 UTC.
What a Unix Timestamp Actually Means
Table of Contents
A Unix timestamp is a compact way to store time as a number. Instead of saving “Tuesday, 14 November 2023 at 22:13:20 UTC,” a system can store 1700000000. That number is easier for computers to sort, compare, transmit, and index.
The format is common because it avoids many display problems. Databases do not need to store month names. APIs do not need to guess local formats. Log files stay short. Sorting works cleanly because a larger timestamp means a later moment.
The catch is that a Unix timestamp is usually based on UTC. Your local time zone is applied later. If a server stores 1700000000, a user in New York, Berlin, and Tokyo may see different clock times for the same exact moment.
Seconds vs Milliseconds: The Mistake That Breaks Everything
The most common problem is unit confusion. Some systems store Unix time in seconds. Others store it in milliseconds. JavaScript, for example, commonly works with milliseconds in its Date object [source: MDN].
That means these two values may describe the same broad period, but they are not interchangeable:
1700000000= seconds-based Unix timestamp.1700000000000= milliseconds-based Unix timestamp.
A quick rule helps:
- 10 digits often means seconds.
- 13 digits often means milliseconds.
- 16 digits may mean microseconds.
- 19 digits may mean nanoseconds.
It drives me crazy that many dashboards do not label this clearly. You paste a value, it “works,” and then you notice the date is somewhere in 1970 or 55840. That tiny missing label can cost 20 minutes of checking filters, exports, and time zone settings.
How to Convert a Unix Timestamp Manually
If the timestamp is in seconds, the logic is simple. Start at 1970-01-01 00:00:00 UTC. Add the number of seconds. The resulting moment is the converted time.
For milliseconds, divide by 1000 first:
1700000000000 ÷ 1000 = 1700000000- Then convert
1700000000as seconds.
You rarely need to do that by hand, but knowing the rule helps you spot bad data fast. If a timestamp is 13 digits and your tool expects 10, divide by 1000. If a timestamp is 10 digits and your tool expects milliseconds, multiply by 1000.
Easy Conversion Methods
Use the method that matches your workflow. The best option is often the one already inside your tool stack.
1. Convert in JavaScript
JavaScript expects milliseconds when creating a date from a numeric timestamp.
const timestamp = 1700000000;
const date = new Date(timestamp * 1000);
console.log(date.toISOString());
This returns:
2023-11-14T22:13:20.000Z
If your input is already in milliseconds, do not multiply it again.
2. Convert in Python
Python makes conversion clean:
from datetime import datetime, timezone
timestamp = 1700000000
dt = datetime.fromtimestamp(timestamp, tz=timezone.utc)
print(dt)
Output:
2023-11-14 22:13:20+00:00
Use UTC unless you have a strong reason not to. It keeps logs consistent and reduces hidden offset errors.
3. Convert on Linux or macOS
On many Unix-like systems, use the date command:
date -r 1700000000 -u
On GNU/Linux, this form is common:
date -d @1700000000 -u
Small command differences are annoying. macOS and Linux do not always use the same flags, so check your system before adding the command to scripts.
4. Convert in Spreadsheets
Spreadsheets are useful for logs, exports, reports, and quick audits. For seconds-based Unix time in cell A2, use:
=A2/86400 + DATE(1970,1,1)
Why 86400? There are 86,400 seconds in a standard day. After using the formula, format the cell as a date and time.
For milliseconds, use:
=A2/1000/86400 + DATE(1970,1,1)
Best Practices for Reliable Timestamp Conversion
Good timestamp handling is about discipline. The conversion itself is not hard. The risk comes from missing context.
- Store in UTC. Apply local time zones only when displaying data.
- Label the unit. Use names like
created_at_unix_secondsorevent_time_ms. - Keep raw values. Do not overwrite the original timestamp during cleanup.
- Document time zones. Reports should say whether times are UTC or local.
- Test with known values. Convert one timestamp by two methods before processing a large file.
For teams, naming matters. A field named time tells you almost nothing. A field named event_timestamp_utc_ms prevents guesswork. That may sound dull, but it saves real money when audit logs, payments, user sessions, or compliance records are involved.
Common Use Case: Web Analytics Cleanup
Picture a marketing analyst receiving a CSV export from an event tracking system. It has 120,000 rows. The column event_time contains values like 1698796800000. The analyst imports it into a spreadsheet and uses a seconds-based formula. The dates look wrong, but not obviously broken at first glance.
The fix is simple. The timestamp is in milliseconds, so it must be divided by 1000 before date conversion. After correction, session records line up with campaign clicks, form submissions, and revenue entries. A report that looked off by days now matches the CRM within 1%.
This is why timestamp checks should happen before analysis. If dates are wrong, every chart built from them becomes suspect.
Practical Checks Before You Trust the Result
Before accepting a converted timestamp, ask a few direct questions:
- Is the value 10, 13, 16, or 19 digits long?
- Does the source system document seconds or milliseconds?
- Was the timestamp created in UTC?
- Does the converted date fall inside the expected business period?
- Are daylight saving changes relevant to the displayed time?
Daylight saving time deserves care. Unix time itself does not “do” daylight saving. It counts seconds from the epoch. The local display layer handles clock shifts. That means the same timestamp stays stable, even if the local time label changes by region.
Final Takeaway
Unix timestamp conversion is easy when you know the unit, time zone, and target format. Treat seconds and milliseconds as separate formats. Convert in UTC first, then display local time only when needed. If a date looks wildly wrong, check the digit length before blaming the tool.
For clean systems, use clear field names, keep raw timestamps, and test conversions with known examples. Those habits prevent silent reporting errors and make logs easier to trust.