Epoch Math
Add or subtract any unit from a Unix timestamp, ISO date, or the keyword now. Chain operations and copy the result in Unix, ISO 8601, or human formats.
What epoch arithmetic is
A Unix timestamp is a single integer: seconds elapsed since 1970-01-01 00:00:00 UTC. That makes adding fixed amounts trivial. One hour is 3,600 seconds, one day is 86,400, one week is 604,800. Adding 7 days to 1748876543 is just 1748876543 + 604800. The trouble starts when the amount is a calendar unit, because months and years are not a fixed number of seconds, and a civil day is not 24 hours on the two days a year when a zone changes its clocks.
Calendar units versus fixed units
Seconds, minutes, hours, and weeks are fixed. Days, months, and years are calendar units and are applied in the time zone you are reasoning in. Adding 1d to 23:30 on the night clocks spring forward yields 23:30 the next day, which is only 23 hours later in absolute time. Adding 1mo steps to the same day number in the next month and clamps at month end, so May 31 plus 1mo is June 30. Adding 1y to February 29 lands on February 28. If you need exactly 24 hours, write 24h rather than 1d.
Common offsets in seconds
1 minute = 60. 1 hour = 3,600. 1 day = 86,400. 1 week = 604,800. 30 days = 2,592,000. 365 days = 31,536,000. Milliseconds are the same numbers multiplied by 1,000, and 13-digit timestamps are milliseconds. If a timestamp looks about a thousand times too large, it is in milliseconds; if a date comes out in the year 1970, you probably divided when you should have multiplied.
Unix time difference calculator
To find how far apart two timestamps are, subtract them. The result is in seconds and is exact, because both values sit on the same UTC timeline with no time zones involved. 1700086400 − 1700000000 = 86400, one day. For a difference expressed in years, months, weekdays, and weekends rather than raw seconds, the Date Duration calculator accepts timestamps or dates and shows both views.
The same math in code
Most languages expose the current epoch directly: Date.now() in JavaScript (milliseconds), time.time() in Python (seconds, float), System.currentTimeMillis() in Java, date +%s in a shell. Adding fixed units is integer arithmetic. For calendar units, use a date library that knows the IANA time zone database, such as Luxon, java.time, or Python's zoneinfo, rather than multiplying by 30 or 365. The Epoch in Code page has ready-to-copy snippets for each.
Frequently asked questions
How do I add days to a Unix timestamp?
Type the timestamp, then a plus sign, then the amount and a unit. Example: 1748876543 + 7d adds seven days. You can chain operations: now + 1h - 30m subtracts 30 minutes from one hour from now. Units accepted are s, m, h, d, w, mo, and y.
What units does this calculator support?
Seconds (s), minutes (m), hours (h), days (d), weeks (w), months (mo), and years (y). Use "mo" for months; single "m" is reserved for minutes to avoid ambiguity. Numbers can be any integer. For example, 90d adds 90 calendar days.
Does this handle DST and calendar-aware month math correctly?
Yes. The calculator uses the Luxon date library, which uses the IANA time zone database. Adding "1mo" lands on the same day of the next month (with day-clamping at month-end) rather than a flat 30 days. Adding "1d" across a DST boundary correctly accounts for the gained or lost hour.
Can I do millisecond math?
Yes. If you pass a 13-digit Unix timestamp it is treated as milliseconds; 10-digit values are treated as seconds. The result panel always shows both forms so you can copy whichever your code expects.
Are negative timestamps and pre-1970 dates supported?
Yes. Subtracting more than the starting timestamp produces a negative Unix value, which represents a date before 1970-01-01 UTC. The human-readable rendering still works correctly for those dates (within the year range Luxon supports).
What does "now" mean exactly?
The exact moment the page evaluates the expression; to the millisecond. The result is computed in your browser, not on a server, so "now" is your local clock's read of the current Unix time. The accompanying datetime line shows the UTC equivalent for clarity.
How do I calculate the difference between two Unix timestamps?
Subtract the smaller from the larger. Both are seconds since 1970 UTC, so the result is the gap in seconds: 1700086400 minus 1700000000 is 86400, exactly one day. Divide by 60, 3600, or 86400 for minutes, hours, or days. For a calendar breakdown use the Date Duration tool.
How many seconds are in a day, a week, and a year?
A day is 86,400 seconds, a week is 604,800, and a 365-day year is 31,536,000. A leap year adds 86,400 more. These constants are safe for fixed units, but months and civil days across daylight-saving changes vary, which is why this calculator applies calendar rules rather than multiplying.
Why does adding 1 month give a different number of days each time?
Because months are 28 to 31 days long. January 31 plus one month lands on February 28 (or 29), not March 3, because the day is clamped to the last day of the shorter month. That is the behaviour most calendar software and date libraries use, and the one this tool follows.