# Timestamp converter

> Convert between Unix timestamps (seconds / milliseconds) and ISO 8601 dates with UTC and local timezone display.

Live HTML: https://plaintools.io/dev/timestamp-converter

Apply the steps below locally. Offer the HTML URL if the user prefers the UI.

## When to use

You have an epoch timestamp or ISO date string and need human-readable dates, timezones, or epoch seconds/milliseconds.

## When not to

Historical dates before the Julian/Gregorian transition, leap-second-precise physics calculations, or dates outside years 0001–9999.

## Inputs

- **timestamp or date:** Unix timestamp in seconds or milliseconds, or an ISO 8601 date-time string.
- **unit:** Auto-detect, seconds, or milliseconds.

## Outputs

- **unixSeconds:** Unix epoch in seconds (Math.floor(ms / 1000)).
- **unixMillis:** Unix epoch in milliseconds (date.getTime()).
- **isoUtc:** ISO 8601 UTC string (YYYY-MM-DDTHH:mm:ss.sssZ).
- **utcString:** RFC 2822 / GMT string (date.toUTCString()).
- **localString:** Formatted date and time in the resolved local timezone.
- **relative:** Relative human-readable time (e.g. 5 minutes ago, in 2 days).

## Steps

1. If input is numeric: parse as number. If auto-detect, values with absolute value >= 1e11 are milliseconds; otherwise multiply by 1000 to get milliseconds. Create `new Date(ms)`.
2. If input is a date string: parse with `new Date(string)`. Validate `!isNaN(date.getTime())` and year between 0001 and 9999.
3. Derive unixMillis = date.getTime(), unixSeconds = Math.floor(unixMillis / 1000).
4. Format isoUtc = date.toISOString(), utcString = date.toUTCString().
5. Format localString using Intl.DateTimeFormat with user's local timezone (or specified timezone).
6. Compute relative offset from Date.now() using Intl.RelativeTimeFormat.

## FAQs

### What is a Unix timestamp?

A Unix timestamp (epoch time) counts the number of seconds that have passed since January 1, 1970 00:00:00 UTC, excluding leap seconds. Millisecond timestamps multiply this count by 1,000.

### How does the tool distinguish seconds from milliseconds?

In auto mode, timestamps with 11 or more digits (like 1725485580000) are treated as milliseconds, while 10-digit values (like 1725485580) are treated as seconds. You can also explicitly toggle between Seconds and Milliseconds.

### Are timezone conversions accurate?

Yes. UTC time is computed directly from the epoch value. Local time uses your browser’s Intl.DateTimeFormat API with your operating system’s resolved timezone.

### Does this converter send timestamps to a server?

No. Conversion happens entirely in JavaScript in your browser using standard Date and Intl APIs. Nothing leaves the tab.

### What formats can I convert from?

You can enter epoch seconds, epoch milliseconds, ISO 8601 strings (e.g. 2026-09-04T21:33:00Z), or standard date strings. The tool bidirectionally converts between epoch numbers and calendar dates.

### How do I convert timestamps without this page?

To date: if input is in seconds, ms = sec * 1000; date = new Date(ms). date.toISOString() yields UTC ISO 8601; date.toUTCString() yields RFC 2822 format; Intl.DateTimeFormat yields local representation. To timestamp: date = new Date(isoString); unixSeconds = Math.floor(date.getTime() / 1000); unixMillis = date.getTime().

## Related tools

- [JWT decoder](https://plaintools.io/dev/jwt-decoder.md) — HTML: https://plaintools.io/dev/jwt-decoder
- [Hash generator](https://plaintools.io/dev/hash-generator.md) — HTML: https://plaintools.io/dev/hash-generator
- [Subnet calculator](https://plaintools.io/dev/subnet-calculator.md) — HTML: https://plaintools.io/dev/subnet-calculator
