A Unix time epoch calculator converts a date and time into a Unix timestamp, or converts a timestamp back into a readable date. Enter a date and time with its time zone to get seconds since the Unix epoch; in the reverse direction, enter the timestamp to see the corresponding date and time.
Formula
Unix time is the number of elapsed seconds from 1970-01-01 00:00:00 UTC. The calendar-date calculation is shown here for years 1970–9999 and uses the Gregorian leap-year rule: a year is a leap year when divisible by 4, except century years unless divisible by 400. The calculator’s simplified month term above is not a valid general Gregorian date conversion, so it should not be used to produce authoritative timestamps for arbitrary dates. For accurate conversion, use a date-time library or the calendar algorithm described below.
For a precise calculation, first count the days from 1970-01-01 to the chosen date using the Gregorian calendar. Then calculate:
Unix seconds = days since 1970-01-01 × 86,400 + hour × 3,600 + minute × 60 + second.
- Days since epoch is the signed count of calendar days from 1970-01-01; dates before the epoch have a negative count.
- Hour is 0–23, minute is 0–59, and second is normally 0–59.
- For a local time, convert it to UTC before calculating. A time-zone offset east of UTC is subtracted from the local clock time; an offset west of UTC is added.
Worked Example
Using the default date and time, 2024-01-01 00:00:00, the exact result is 1,704,067,200 Unix seconds. This is calculated by counting 19,723 days from 1970-01-01 through 2023-12-31, then multiplying:
19,723 × 86,400 = 1,704,067,200 seconds.
The calculator block’s formula does not give this result: its month approximation is not calendar-accurate. Do not rely on that block for conversion. A working calculator must use a correct Gregorian date algorithm and validate that each month actually contains the selected day; the displayed fields are included only to illustrate the intended inputs.
What Unix Time Means
The Unix epoch is the reference instant 1970-01-01 at 00:00:00 Coordinated Universal Time (UTC). A timestamp of 0 means that instant. A positive value represents a later instant, while a negative value represents an earlier one. For example, 1,000 means 1,000 seconds after the epoch, or 16 minutes and 40 seconds.
Unix time is commonly used in programming, databases, logs, APIs, and file metadata because a single number is convenient for comparing and calculating instants. The unit is often seconds, but software may store milliseconds, microseconds, or nanoseconds instead. A timestamp is not fully interpretable until its unit is known.
Seconds, Milliseconds, and Other Units
Seconds are the traditional Unix timestamp unit, but many web interfaces and programming environments use milliseconds. The same instant might be represented as 1,704,067,200 seconds or 1,704,067,200,000 milliseconds. To convert seconds to milliseconds, multiply by 1,000; to convert milliseconds to seconds, divide by 1,000.
- 10-digit values are often seconds for dates in the present era.
- 13-digit values are often milliseconds.
- 16-digit and 19-digit values may be microseconds or nanoseconds.
Digit counts are clues, not proof. Negative timestamps and dates far in the past or future do not follow those rough patterns. Check the data format’s documentation rather than guessing from the number alone.
Time Zones, Daylight Saving, and Leap Seconds
Unix time describes an instant, not a time zone. The timestamp itself does not say whether someone intended a clock reading in New York, Tokyo, or another location. To convert a civil date and time correctly, you need its time zone or UTC offset. For example, midnight in one region can correspond to the previous date in UTC.
Daylight-saving changes create local clock times that may be ambiguous or nonexistent. When clocks move backward, a local time can occur twice; when clocks move forward, some local times do not occur at all. A time-zone-aware calculator needs a location-based time zone and a rule for resolving such cases. A fixed offset alone may not capture historical or seasonal changes.
Unix time generally treats days as 86,400 seconds and does not represent leap seconds as ordinary timestamp seconds. UTC occasionally includes a leap second to keep civil time aligned with Earth’s rotation, but common Unix timestamp systems handle it differently or omit it. For most everyday software tasks this distinction is not noticeable; precision timing and scientific applications need a clearly specified time standard.
Common Errors and Reliable Conversion
- Mixing units: A millisecond timestamp interpreted as seconds produces a date thousands of years away. Confirm whether the value is seconds, milliseconds, microseconds, or nanoseconds.
- Ignoring the time zone: A date-time without a zone is not enough to identify one unique instant. State UTC or provide the intended local zone.
- Using invalid calendar dates: Month lengths vary, and leap years add February 29. A valid converter should reject impossible dates, such as April 31.
- Rounding fractional seconds too early: Preserve fractional precision during calculations, then round only to the precision needed for display or storage.
- Assuming every system has the same range: Programming languages and databases may use different integer widths, supported date ranges, and conventions for negative timestamps.
For dependable conversions, use a date-time library that supports the Gregorian calendar and explicit time zones. Check that it expects the timestamp’s actual unit, and prefer UTC for storing and exchanging instants. Convert to a local time zone for display, not as a substitute for recording the original zone when that information matters.
Frequently Asked Questions
What is the Unix epoch date?
The Unix epoch is 1970-01-01 00:00:00 UTC. Its Unix timestamp is 0 seconds.
How do I convert Unix time to a date?
Identify the timestamp unit, convert the value to seconds if necessary, and add that elapsed time to the epoch. Use a date-time library to format the result in UTC or a specified time zone.
Is Unix time always in seconds?
No. Seconds are common, but systems also use milliseconds, microseconds, and nanoseconds. Verify the unit for the specific API, database, or file format.
Can Unix timestamps be negative?
Yes. A negative timestamp represents time before 1970-01-01 00:00:00 UTC, although software support for earlier dates varies.
Does a Unix timestamp include a time zone?
No. It identifies an instant relative to the UTC epoch. A time zone is needed to display that instant as a local civil date and clock time.
Related
Formula used
in y | Year | year | 2024 | 1970 | 9999 in mo | Month | month | 1 | 1 | 12 in d | Day of month | day | 1 | 1 | 31 in h | Hour | h | 0 | 0 | 23 in mi | Minute | min | 0 | 0 | 59 in s | Second | s | 0 | 0 | 59 out t | Unix time | s | (y - 1970) * 31536000 + floor((y - 1969) / 4) * 86400 - floor((y - 1901) / 100) * 86400 + floor((y - 1601) / 400) * 86400 + floor((mo - 1) * 30.436875) * 86400 + (d - 1) * 86400 + h * 3600 + mi * 60 + s | 0
Each line is one input (in, sel, list) or one result (out: label, unit, formula, decimals). How the calculators work
Method: the standard formula for this calculation with the constants and conversion factors written on the page, rounded as each result states. See method and constants, the disclaimer or report an error.
More in this section
- MD Calc I:T Ratio Calculator and Explanation0.0500 ratio
- Oxygen Mass Number: Isotope Values Explained16 nucleons
- Mass-to-Light Ratio: Meaning and Calculation1.000 M☉/L☉
- M/z Ratio in Mass Spectrometry: Meaning and Calculation1,000.00 Th
- Mass Fraction to Molar Fraction Calculator
- K2 Molar Mass Calculator and Calculation78.1966 g/mol