Developer

How to Convert a Unix Timestamp to a Date

Dev Nexus5 min read

A practical walkthrough for turning a raw Unix timestamp into a readable local, UTC or ISO date - and converting a date back into a timestamp.

You are staring at a log line, a JSON field or a database row that says 1752796800, and you need to know what date that actually is. That number is a Unix timestamp - a count of seconds since a fixed starting point - and turning it into a date you can read takes only a moment once you know the rules.

This guide walks through converting a Unix timestamp to a date in every format you are likely to need: your local time, UTC, and the ISO undefined string that APIs prefer. It also covers the reverse - turning a date back into a timestamp - and the one detail that trips almost everyone up: seconds versus milliseconds.

The Problem

A Unix timestamp is deliberately not human-friendly. It is a single integer, with no timezone, no separators and no hint of the year, month or day. That compactness is exactly why systems love it, but it means you cannot read it at a glance.

Manual conversion is error-prone. Divide by the wrong unit and you land decades off. Forget about timezones and an event that happened at undefinedpm local looks like it happened at midnight. Assume UTC when the value was local - or the reverse - and your times drift by hours. When you are debugging an expiry, a schedule or an audit trail, those mistakes send you chasing the wrong problem.

The Solution

The reliable approach is to convert with a tool that shows every representation at once, so you never have to guess the unit or the timezone. Paste the number and read it back as local time, UTC and ISO undefined side by side.

The Timestamp Converter does exactly this in your browser - nothing is uploaded, which matters when the value came straight out of production logs. It detects whether the number is in seconds or milliseconds, renders the moment in each format, and works in reverse too: pick a date and get the epoch value back.

If you need the elapsed time between two dates rather than a single instant, the Date Difference calculator is the companion tool for that job.

Step-by-Step Guide

  1. 1

    Identify the unit

    Look at the digit count. A current timestamp in seconds is undefined digits (like 1752796800); in milliseconds it is undefined digits (like 1752796800000). Getting this right first avoids the most common conversion error - being off by a factor of undefined, which throws the date thousands of years out.

  2. 2

    Convert to a date

    Paste the timestamp into the converter. It parses the number and produces the exact moment it represents. In code, that is new Date(seconds * 1000) in JavaScript, since the Date constructor expects milliseconds - another reason to be sure of your unit.

  3. 3

    Pick the timezone view you need

    Read the result as local time when you want the wall-clock time in your own region, or as UTC when you need the canonical, timezone-free instant for comparing across systems. The underlying moment is identical; only the displayed offset differs.

  4. 4

    Copy the ISO 8601 string for machines

    For APIs, config files and anything another program will parse, copy the ISO undefined form (2026-07-18T00:00:00Z). It is unambiguous, sortable as plain text and understood by virtually every language.

  5. 5

    Reverse it when you need a timestamp

    To go from a date back to epoch, pick the calendar date and time and read off the timestamp in seconds or milliseconds. This is what you paste into a WHERE created_at > ... query or an API request.

Common Mistakes

  • Mixing up seconds and milliseconds

    This is the classic bug. Passing a milliseconds value to a seconds parser (or vice versa) produces a date wildly in the past or future. Check the digit count - undefined for seconds, undefined for milliseconds - before you convert.

  • Ignoring the timezone

    A timestamp is a single instant, but the displayed date depends on the timezone you render it in. If you compare a local-rendered time against a UTC one without accounting for the offset, they will look different even though the underlying moment is the same.

  • Assuming the input is in seconds

    JavaScript's Date.now() and many web APIs return milliseconds, not seconds. Do not assume every timestamp is Unix seconds - confirm the unit from the source before converting.

  • Trusting a server-side web converter with sensitive logs

    Many online converters POST your input to a server. When the value comes from production data, prefer a tool that converts locally in the browser so nothing leaves your machine.

Frequently Asked Questions

How do I convert a Unix timestamp to a date?

Determine whether the number is in seconds (10 digits) or milliseconds (13 digits), then convert it. Paste it into the Timestamp Converter to see the local, UTC and ISO 8601 forms at once, or in JavaScript use new Date(seconds * 1000).

How do I convert a date back into a Unix timestamp?

Pick the date and time you want and read off the epoch value. The converter returns both seconds and milliseconds. In JavaScript, Math.floor(new Date('2026-07-18').getTime() / 1000) gives you the seconds value.

Should I use local time or UTC?

Store and compare timestamps in UTC to avoid ambiguity, and convert to local time only when displaying a value to a user. The underlying epoch number is the same in both cases.

Why does my converted date look completely wrong?

Almost always a unit mismatch. If a date lands in the year 55000 or in 1970, you have likely fed milliseconds into a seconds parser or the reverse. Recheck the digit count of the input.

Is it safe to convert production timestamps online?

Only if the tool runs locally. The Timestamp Converter does all work in your browser and uploads nothing, so values from logs, tokens or databases stay on your device.

Try the Tool

Timestamp Converter

Convert any Unix timestamp to a date - and back - in your browser, nothing uploaded.

Open Timestamp Converter

Related Tools

Related Articles