Timeplain

Unix Timestamp / Epoch Converter

Convert Unix epoch timestamps to dates and local times, or dates to timestamps. Copy ISO 8601, RFC 3339, and code examples for JavaScript, Python, PHP, and SQL.

Help & feedback
Convert from

Seconds or milliseconds since January 1, 1970 UTC.

Result

Timezone
—
Offset
—

Other formats

Convert a time to see its formats.

ISO 8601 and RFC 3339 UTC values match for ordinary dates. HTTP dates use whole seconds. RFC 3339 and HTTP dates require a four-digit year.

Show code for your converted time

Your converted time in code

Examples use the resolved instant and destination timezone. JavaScript uses Unix milliseconds; PHP parses an explicit UTC date; Python uses timezone-aware dates. Ruby uses TZInfo for named time zones. Java and C++ start from Unix milliseconds. None rely on your computer’s default timezone.

Convert a time to generate an example.

Repeated local times get two separate examples. These reproduce your resolved conversion; they do not validate arbitrary local-time input. JavaScript display text and timezone rules can vary with runtime locale data. PHP examples support four-digit years. Python requires 3.9+ and supports years 1–9999. If timezone data is missing, install it with python -m pip install tzdata. Ruby requires the TZInfo 2.x gem and timezone data (install tzinfo-data if needed). Ruby examples support years 0000–9999 in UTC and the destination timezone. Java requires 8+. C++ requires a C++20 standard library with chrono timezone support, std::format, and installed IANA timezone data. Java and C++ examples support years 0000–9999 in UTC and the destination timezone.

Use this in a database

Convert between Unix timestamps and UTC database dates. MongoDB uses milliseconds; SQL examples return seconds. Each example includes both directions and a copy button.

Convert a time to generate an example.

Examples use UTC, regardless of the selected display timezone. MySQL / MariaDB changes the current connection’s timezone and uses a portable 1970–2038 range. PostgreSQL examples support years 1–9999; SQLite supports 0000–9999 and requires 3.42+. Database clients may display different trailing zeros. SQL Server requires 2016+ and supports years 1–9999. MongoDB examples support years 0000–9999; aggregation requires MongoDB 6.0+. Repeated local times get separate examples.

Understanding timestamps and time zones

How to convert a timestamp or local date

Select Timestamp or Date / Time, choose a timestamp format, enter a value, and choose your time zones. For a local date, the source timezone determines the instant. A timestamp already identifies an instant; the destination timezone changes how it is displayed. Use the copy buttons for formats and code examples.

Understanding Apple dates

Apple / Cocoa timestamps count seconds from January 1, 2001 at midnight UTC. Apple’s Foundation Date API still supports this reference date. For example, Cocoa timestamp 0 is January 1, 2001, and corresponds to Unix timestamp 978307200. Add 978307200 to Cocoa seconds to get Unix seconds.

Mac HFS+ is a legacy format that counts whole seconds from January 1, 1904 UTC. Subtract 2082844800 from an HFS+ timestamp to get Unix seconds. Its unsigned 32-bit range ends on February 6, 2040 at 06:28:15 UTC.

Select the format that matches your data. This tool accepts Cocoa seconds with up to three decimal places, not nanosecond counts. The code examples use the converted instant with each language’s date conventions; they do not use raw Apple timestamps.

Unix seconds versus milliseconds

Epoch time is another name for Unix time: elapsed time since January 1, 1970 at 00:00:00 UTC, without counting leap seconds. Milliseconds are seconds multiplied by 1,000. For example, 1,000 Unix seconds and 1,000,000 Unix milliseconds both represent January 1, 1970 at 00:16:40 UTC. Choose the unit explicitly when automatic detection does not match your input.

UTC, offsets, and named time zones

UTC provides a shared reference for an instant. An offset such as +01:00 describes the difference from UTC at that instant. A named timezone such as Europe/London also includes historical and daylight-saving rules, so its offset can change through the year.

Why a local time can have two answers—or none

When clocks move back, a local time can occur twice. Timeplain shows both instants so you can choose the intended one. When clocks move forward, some local times are skipped; the converter reports the gap instead of silently shifting your input.

Copy date formats and conversion code

Other formats includes Unix seconds and milliseconds, ISO 8601, RFC 3339, and HTTP dates. ISO and RFC values include UTC or an offset; HTTP dates use whole seconds. Generate JavaScript, PHP, Python, Ruby, Java, and C++ examples, or database examples for MySQL/MariaDB, PostgreSQL, SQLite, SQL Server, and MongoDB. Each example states its runtime and timezone assumptions.

Unix timestamp example

Unix timestamp 1700000000 represents 2023-11-14T22:13:20.000Z in UTC and November 14, 2023 at 5:13:20 PM EST in America/New_York. The same instant is 1700000000000 Unix milliseconds.

JavaScript

              // JavaScript Date takes milliseconds, not Unix seconds.
const timestampMs = 1700000000000;
const date = new Date(timestampMs);
const timeZone = "America/New_York";

console.log(date.toISOString());
console.log(new Intl.DateTimeFormat('en-GB', {
  timeZone,
  dateStyle: 'full',
  timeStyle: 'long',
}).format(date));
            

Output: 2023-11-14T22:13:20.000Z Tuesday, 14 November 2023 at 17:13:20 GMT-5

MySQL / MariaDB

              -- Set UTC for this connection before running both queries.
SET SESSION time_zone = '+00:00';

-- Unix seconds to a UTC datetime (fractional seconds preserved).
SELECT FROM_UNIXTIME(1700000000) AS utc_datetime;

-- UTC datetime back to Unix seconds.
SELECT UNIX_TIMESTAMP('2023-11-14 22:13:20.000') AS unix_seconds;
            

Expected UTC values: utc_datetime: 2023-11-14 22:13:20.000 unix_seconds: 1700000000

Unix timestamp questions

Are Unix timestamps in seconds or milliseconds?

Both are common. Unix seconds count seconds since 1970-01-01 00:00:00 UTC; milliseconds are that value multiplied by 1,000. Use the unit selector when automatic detection does not match your value.

Does changing the timezone change a Unix timestamp?

No. A Unix timestamp identifies one instant. Changing the timezone changes only the local date and time used to display that instant.

What is the Year 2038 problem?

Systems that store Unix seconds in a signed 32-bit integer reach their maximum value on 2038-01-19 at 03:14:07 UTC. Systems using wider timestamp storage are not limited by that 32-bit boundary.

Feedback

Have a suggestion, spotted a problem, or need another date format? Help shape what comes next for Timeplain.

For conversion issues, include your input, selected time zones, and the result you expected. Maximum 2,000 characters.

Your feedback and optional email are stored privately for review. Include your email if you would like a reply. Please don’t include passwords or other sensitive information.