Unix epoch time counts seconds since 1 January 1970, 00:00:00 UTC. It is the standard timestamp behind most software, logs, and APIs, and converting a human date to epoch time is a skill that saves debugging time.
How it works
The conversion has three parts: days from 1970-01-01 to your date, times 86,400 seconds per day, plus seconds since midnight in UTC. Days are counted with leap years included: every year divisible by 4 adds a leap day, except century years not divisible by 400. The critical step is timezone: epoch time is always UTC, so a local time must first be converted to UTC by subtracting the local offset.
Step by step
- Convert your local time to UTC by applying the timezone offset.
- Count full years from 1970 to the year before your date, adding leap days.
- Add the days of the full months before your month in your year, using the leap-year February if needed.
- Add day of month minus 1 for days before today.
- Multiply total days by 86,400.
- Add hours x 3600 + minutes x 60 + seconds for the time of day in UTC.
Worked example
Convert 1 January 2026, 00:00:00 UTC. Years 1970 to 2025 inclusive: 56 years, of which 14 are leap years (1972 through 2024, including 2000, which is divisible by 400). Days = 56 x 365 + 14 = 20,454. Epoch = 20,454 x 86,400 = 1,767,225,600 seconds. A local time of noon in UTC+2 is 10:00 UTC, so subtract 2 hours, or 7,200 seconds, before converting.
Common mistakes
- Converting local time directly without shifting to UTC, which offsets the result by hours.
- Forgetting leap days, which drifts the result by days over long spans.
- Using 1900 or 1970-01-01 local midnight instead of UTC midnight as the epoch start.
- Confusing seconds with milliseconds. Epoch milliseconds are seconds times 1000.
Try it with the free tool
You can follow every step above by hand, but the free tool below does the same calculation instantly. Try your own numbers in it, then check one result by hand so you trust the method as well as the answer. Open the full tool here: open the tool.
Checklist before you finish
- Write down every input number first, with its unit, before you calculate anything.
- Work through the steps in order, and do not skip the unit conversions.
- Check the answer against the worked example above: is it the right size, and does the direction make sense?
- Round only at the end, and keep the unrounded figure for any follow-up calculation.
Practice with your own numbers
Pick three cases of your own and work each one by hand. First, try a simple round-number case you can check mentally. Second, try a realistic case with awkward numbers, the kind you will actually meet. Third, try an edge case, such as a very small or very large input, and confirm the answer still behaves sensibly. If any case gives a surprising result, re-check the units and the formula step by step before you trust it.
If your answer looks wrong
Most errors come from a small set of causes. Check that you used the same units throughout, that you divided where the formula divides and multiplied where it multiplies, and that you applied any percentage as a decimal. Check the order of operations: powers and brackets come before multiplication and division, which come before addition and subtraction. Finally, test the method on the worked example in this guide. If your method reproduces the example answer, the method is right and the inputs deserve a second look.
Quick tips
For a quick check, convert your epoch result back with a converter and confirm the date and UTC time match. If they differ by a whole number of hours, the timezone step is the culprit.
