Add or Subtract Time From a Date
Add or subtract any combination of years, months, weeks, days, hours, minutes and seconds from a starting date and time to find the resulting moment.
yr
mo
wk
d
h
min
s
How does this calculator work?
Enter a base date-time and signed year, month, week, day, hour, minute and second offsets. The tool adds the year and month parts as calendar adjustments, then adds the remaining parts as a fixed millisecond span, returning the resulting date-time, its weekday, and the total shift in days and seconds.
Formula
How this is calculated
Start with a base date-time entered in ISO format (for example 2026-06-27T09:00). Each offset field accepts a positive value to add time or a negative value to subtract it. The calculation applies the offsets in two stages so the result matches everyday calendar expectations.
First the calendar parts are applied: the year offset is added with setFullYear and the month offset with setMonth. These respect variable month lengths and leap years, so "one month" lands on the same day-of-month where possible (with JavaScript Date normalising end-of-month overflow). After that the elapsed-time parts — weeks, days, hours, minutes and seconds — are converted to a single millisecond span using (Δd + 7·Δw)·86400 + 3600·Δh + 60·Δmi + Δs, multiplied by 1000, and added to the date.
The output shows the resulting date-time, its weekday, and the total shift expressed both in days and in seconds (the difference between the final and starting instants). Note the total-day and total-second figures are measured against the local time line, so transitions like daylight-saving changes in the host time zone can make the elapsed seconds differ slightly from the nominal offsets.
Frequently asked questions
Enter a negative number in any offset field. For example, type -3 in the Days field to move three days into the past. You can mix positive and negative offsets freely.
Months have different lengths, so the tool adjusts the calendar month rather than adding a fixed 30 days. Adding one month to January 31 lands in early March because February has fewer days, which is standard calendar behaviour.
Years and months are applied first as calendar adjustments, then weeks, days, hours, minutes and seconds are added as a fixed elapsed-time span. This ordering keeps month-end and leap-year results intuitive.
Also known as
TG we-Calculate Editorial Team. (2026). Add or Subtract Time From a Date [Online calculator]. TG we-Calculate. https://we-calculate.com/calculator/add-subtract-time
TG we-Calculate Editorial Team. "Add or Subtract Time From a Date." TG we-Calculate. 2026. https://we-calculate.com/calculator/add-subtract-time.
TG we-Calculate Editorial Team, "Add or Subtract Time From a Date," TG we-Calculate, 2026. [Online]. Available: https://we-calculate.com/calculator/add-subtract-time
@misc{wecalculate_add_subtract_time, title = {Add or Subtract Time From a Date}, author = {{TG we-Calculate Editorial Team}}, howpublished = {\url{https://we-calculate.com/calculator/add-subtract-time}}, year = {2026}, note = {TG we-Calculate} }
Did this calculator help you?
