A Unix timestamp is the number of seconds that have elapsed since the Unix epoch, 1970-01-01T00:00:00Z (UTC), and converting one to a human-readable date in Python means moving that raw integer into a datetime object through either the datetime or time module. Python's built-in approach is fast, scriptable, and reproducible, so it is the right choice when the conversion has to happen inside a running pipeline, an API handler, or a data-cleaning script that touches hundreds of rows at once. The trade-off is that you have to keep two details straight: the unit (seconds versus milliseconds) and the timezone (UTC versus your local clock). Get either of those wrong and a perfectly correct epoch number suddenly reads as 1970 or as a date in the year 55000. For ad-hoc decoding — staring at a log line, an API payload, or a database column and wanting to know what time it actually represents — a free in-browser Unix Timestamp Converter gives you four views at once: ISO 8601, a readable UTC string, your device's local time, and a relative label like "3 hours ago." This guide covers the Python angle first, then walks through the browser tool so you can pick the right approach for the moment.

how to convert unix timestamp to date in python
How to Convert Unix Timestamp to Date in Python

What a Unix Timestamp Actually Is

A Unix timestamp — also called epoch time, or simply Unix time — is the number of seconds that have elapsed since 1970-01-01T00:00:00Z, the moment that counts as zero in the Unix world's clock. According to Wikipedia's entry on Unix time, that reference instant is defined in UTC and is the same no matter which language, operating system, or database engine you ask. The format is just a plain integer that ticks upward at one unit per second, with no timezone attached and no leap-second corrections built in.

That simplicity is exactly why the value is everywhere: server logs, REST and GraphQL API responses, JWT expiry claims, cron schedules, Git commit metadata, and database columns for created_at and updated_at all store time as a plain integer counting up from that 1970 midnight in Greenwich. Compact, unambiguous, and trivially sortable, but completely opaque without a conversion step.

The Python Angle: Working with Epoch Values in Code

Python's standard library makes the conversion a one-liner in either direction through the time module and the datetime module, both of which ship with every default install. For forward conversion — epoch to datetime — the canonical approach is datetime.fromtimestamp(epoch_seconds, tz=timezone.utc). The tz argument is what keeps the result unambiguous; without it, fromtimestamp uses your machine's local timezone, and the same epoch value will read differently on a server in Berlin than on one in San Francisco. The older datetime.utcfromtimestamp() method still works on most active Python versions but is deprecated as of Python 3.12 in favor of the explicit-timezone form.

For milliseconds, divide by 1000 first or pass a float: datetime.fromtimestamp(epoch_ms / 1000, tz=timezone.utc). For the reverse direction — datetime to epoch — datetime.timestamp() returns a float that you can round to an integer when you want the classic Unix integer form. Combine that with datetime.now(timezone.utc) when you need "right now" in epoch form, or with a parsed datetime object when you are turning a string back into an integer for storage.

A small concrete example: feeding an epoch value into datetime.fromtimestamp(..., tz=timezone.utc) returns the matching UTC datetime object — the same answer you get when you paste that same date string into the browser tool's Date → Timestamp field. Both approaches produce the same moment in time; the choice between them comes down to whether the conversion lives inside a script or only on your screen.

How to Convert a Unix Timestamp to a Date with the Browser Tool

For one-off decoding — the kind you do while reading a log file, inspecting an API response, or checking a JWT exp claim — opening a browser tab is faster than launching a Python REPL. The Unix Timestamp Converter runs locally and gives you four readable views of the same epoch number at once. The exact sequence:

  1. Open the Unix Timestamp Converter in your browser.
  2. Paste the integer value into the "Timestamp → Date" field.
  3. Pick Seconds or Milliseconds from the unit selector — pick the one that matches the length of your number, or let the tool's auto-detect run if you are not sure.
  4. Read the four views that appear together: the ISO 8601 string (timezone-independent), the UTC string (also UTC, formatted for humans), your device's local time (reflects your machine timezone), and the Relative label (distance from now in plain words like "3 hours ago" or "in 2 days").
  5. To go the other way, paste or type a date into the "Date → Timestamp" field — an ISO 8601 string like 2023-11-14T22:13:20Z, a plain "2023-11-14 22:13:20 UTC", or a natural date — and read the epoch value the tool returns in both seconds and milliseconds.

Seconds vs Milliseconds: The Most Common Mistake

This is the one detail that catches developers more than any other. Unix time counts upward from zero, one unit per second, but JavaScript's Date object, Java's System.currentTimeMillis(), and many HTTP APIs work in milliseconds — a number that is exactly 1000× larger. Mixing them up is the difference between a real timestamp and a date somewhere in the deep past or far future.

The fastest rule of thumb is to count digits. A current epoch value in seconds is about 10 digits long; the same moment in milliseconds is about 13 digits. If your number is around 1,700,000,000 you read immediately as a 2023 or 2024 date. If your number is around 1,700,000,000,000 you have to divide by 1000 first. Feed milliseconds into a seconds field and you land around the year 55000; feed seconds into a milliseconds field and you land in 1970. Both look plausible to the eye but neither matches the time you meant.

Length of number Likely unit Action
~10 digits Seconds Use the Seconds option in the converter
~13 digits Milliseconds Use the Milliseconds option, or divide by 1000 in Python
9 digits or fewer Seconds, very old date Double-check the source and the expected range
14+ digits Microseconds or nanoseconds Not Unix time; convert via the original API

The Unix Timestamp Converter auto-detects by digit count and lets you override the unit, so the seconds-versus-milliseconds decision stays explicit rather than silent — exactly the kind of guard rail that turns "mystery timestamp" tickets into a one-line fix.

Reading the Output: ISO 8601, UTC, and Local Time

When the tool returns four views of the same epoch, each one answers a different question. Knowing which one to copy into a bug report, a chat message, or a database query is part of using epoch values well.

Output view Format example Best for
ISO 8601 2023-11-14T22:13:20.000Z API responses, sort keys, machine-to-machine communication, copy-paste into code
UTC string Tue, 14 Nov 2023 22:13:20 UTC Human-readable timestamps that must stay unambiguous across timezones
Local time 2023-11-14 17:13:20 (depends on device) Confirming what time it was for the user, debugging a UI bug, sanity check
Relative "3 hours ago" / "in 2 days" Slack messages, commit histories, user-facing copy

ISO 8601 and the UTC string are timezone-independent — they say the same thing no matter who reads them. Local time reflects your device, which is exactly the point: it is the view the original user saw at the moment the event was logged.

Going the Other Way: Date Back to Timestamp

The reverse direction is just as common: you have a date string from a config file, an API response, or a screenshot, and you need the epoch integer to feed into another system. The tool handles this through the "Date → Timestamp" field. Paste an ISO 8601 string like 2023-11-14T22:13:20Z, a plain human format like "2023-11-14 22:13:20 UTC", or a natural date, and the tool returns the epoch value in both seconds and milliseconds at the same time. The seconds form is what Python's datetime.fromtimestamp() expects directly. The milliseconds form is what JavaScript's new Date(value) expects directly. Having both at once is the trick that saves a mental division when you are wiring two services together.

The Year 2038 Problem and Why It Matters

The last reason being able to eyeball a raw timestamp matters is the famous Year 2038 problem. Systems that store Unix time in a signed 32-bit integer overflow at 03:14:07 UTC on 19 January 2038 and wrap back to 1901 — a moment that will, for a brief window, look like a perfectly valid timestamp to software that has not been patched. Modern 64-bit platforms are unaffected, and every modern browser stores time in a 64-bit double, so the Unix Timestamp Converter handles dates far beyond 2038 correctly. The bug still lurks in legacy embedded firmware, older database columns that used INT(4) for an epoch value, and any system that has not been touched since the early 2010s. Being able to convert a suspicious-looking epoch number into a date in two seconds is exactly the kind of daily debugging habit that catches the issue before it reaches a customer.

Related reading: Parse a URL in Python and Verify It Against the Browser.

Related reading: Chmod Calculator Explained: Decoding Unix Permissions.