# Unix timestamp converter

Convert Unix timestamps to date and time and back – in seconds, milliseconds, micro- or nanoseconds, for any time zone, with ready-to-use code for PHP, JavaScript, Python, SQL and Bash.

Use online: https://skriptbox.com/en/tools/unix-timestamp-converter

> All conversions run in your browser. Nothing is transmitted.

## How it works

1. **Paste a timestamp** – Paste your timestamp. Seconds, milliseconds, micro- or nanoseconds are detected from its length.
2. **Pick a time zone** – The result is shown in UTC, your time zone and the zone you pick – daylight saving time and half-hour zones included.
3. **Copy the format** – Copy ISO 8601, RFC 3339 or RFC 2822, convert a date back to a timestamp or grab the matching code for your project.

## What is a Unix timestamp?

A Unix timestamp counts the seconds since 1 January 1970, 00:00:00 UTC – the so-called Unix epoch. For example, `1700000000` is 14 November 2023, 22:13:20 UTC. Moments before 1970 are negative.

A timestamp has **no time zone**: it describes the same instant in Berlin, New York and Tokyo. It’s only converted to local time when it’s displayed. That makes it a good fit for storing, sorting and comparing points in time.


## Seconds, milliseconds, micro- and nanoseconds

Not every system counts in seconds. You can usually tell the unit by the number of digits – for present-day dates:

- 10 digits: seconds, e.g. PHP `time()`, MySQL `UNIX_TIMESTAMP()` or `date +%s`
- 13 digits: milliseconds, e.g. JavaScript `Date.now()` or Java `System.currentTimeMillis()`
- 16 digits: microseconds, e.g. Go `time.Now().UnixMicro()`
- 19 digits: nanoseconds, e.g. Go `time.Now().UnixNano()` or Python `time.time_ns()`

The most common mistake is reading milliseconds as seconds: `1700000000000` then turns into a date somewhere past the year 55,000. The other way round, seconds read as milliseconds end up in January 1970.


## Time zones, daylight saving time and leap seconds

Store points in time in UTC or as a timestamp, and convert to local time only when displaying them. Local times are ambiguous: when clocks go forward an hour is skipped, and when they go back an hour occurs twice. A common mistake is storing the server’s local time as if it were UTC – the data is then off by an hour or two.

In MySQL, `TIMESTAMP` is stored as UTC internally and converted to and from the connection’s time zone. `DATETIME`, on the other hand, stores date and time as they are, without a time zone.

Unix time ignores leap seconds: every day has exactly 86,400 seconds. 27 leap seconds have been added since 1972, the last one at the end of 2016. A timestamp therefore differs slightly from the exact number of elapsed seconds, but that doesn’t matter for converting it to a date and time.


## The year 2038 problem

Many older systems store timestamps as a signed 32-bit integer. Its largest value, `2147483647`, is 19 January 2038, 03:14:07 UTC. One second later the value wraps around to `-2147483648` – 13 December 1901.

This affects 32-bit systems with a 32-bit `time_t`, database columns of type `INT` and MySQL’s `TIMESTAMP` type, which only goes up to 2038. The fix is a 64-bit integer such as `BIGINT` or a date type such as `DATETIME`.


## Frequently asked questions

### What is the current Unix timestamp?

The current value is shown at the top of the tool and updates every second. In a terminal, run `date +%s`; in JavaScript, use `Math.floor(Date.now() / 1000)`.


### How do I convert milliseconds to seconds?

Divide the value by 1,000 and round down, e.g. `Math.floor(ms / 1000)` in JavaScript. To go the other way, multiply seconds by 1,000.


### Does a Unix timestamp have a time zone?

No. A timestamp counts seconds since 1970-01-01 00:00:00 UTC and refers to the same instant everywhere. The time zone only comes into play when you display it as a date and time.


### What happens in 2038?

On 19 January 2038 at 03:14:07 UTC, the timestamp reaches the largest value a signed 32-bit integer can hold. Systems that store it that way then jump back to 1901. With 64-bit values, the problem doesn’t occur.


### Can a Unix timestamp be negative?

Yes. Negative values are moments before 1 January 1970 – `-86400`, for example, is 31 December 1969, 00:00:00 UTC. Most programming languages handle them correctly, but MySQL returns `NULL` or 0 for them.


### How can I tell whether a timestamp is in seconds or milliseconds?

By its length: for present-day dates, a timestamp in seconds has 10 digits, one in milliseconds has 13. The tool detects the unit automatically and shows how it read the value.



## Related tools

- [JWT Debugger](https://skriptbox.com/en/tools/jwt-debugger.md) – Decode JSON Web Tokens, verify signatures (HMAC, RSA, ECDSA, EdDSA) and create your own tokens – nothing is transmitted.
- [UUID & ULID Generator](https://skriptbox.com/en/tools/uuid-generator.md) – Generate UUIDs (v4, v7, v5) and ULIDs for free – up to 1,000 at once as a list, JSON or SQL – and decode existing IDs. Nothing is transmitted.
- [JSON Formatter & Validator](https://skriptbox.com/en/tools/json-formatter.md) – Format, minify and validate JSON online – with the exact line and column of each error, clear hints and key sorting. Nothing is uploaded.
