Date Calculator 日期计算器

Calculate days between two dates, or add/subtract days and workdays from a date. 计算两个日期间隔天数,或日期加减天数/工作日。

日期计算

Auto-calculate on date input 输入日期自动计算
计算模式
相差天数
折合月数
0
折合年数
0
包含周数
0
days
输入正数向后推算,负数向前推算
按工作日计算(跳过周末)
已开启工作日计算,将跳过周六、周日,仅按周一至周五推算
结果日期
星期
实际跨越

Date Calculator Guide

This tool supports two modes of date arithmetic: Interval calculates the number of days between two dates along with equivalent years, months, and weeks; Add / Subtract adds or subtracts days from a date to get a result date, with an option to count workdays only. All calculations run locally in your browser.

Calculation Logic

  • Difference (days): Both dates are aligned to midnight in the local time zone, the millisecond difference is divided by 86400000 (milliseconds per day) and rounded to avoid timezone and daylight saving issues.
  • Months: Converted using an average month length of 30.4375 days (365.25 ÷ 12), result rounded to two decimals.
  • Years: Converted using a tropical year of 365.25 days (including leap year compensation), result rounded to two decimals.
  • Weeks: Full weeks and remaining days within the difference, e.g., 364 days = 52 weeks and 0 days.

Workday Definition

When "Count workdays only" is enabled, date addition/subtraction treats Monday through Friday as valid workdays, skipping Saturday and Sunday. Adding/subtracting N workdays means finding the Nth workday encountered (forward or backward) starting from the day after the base date. This tool does not account for public holidays; for holiday-accurate results, manually verify against the holiday schedule.

Workday calculation: starting from the day after the base date, iterate with step 1, skip weekends, and stop when |N| workdays have been accumulated

Leap Years

Gregorian leap year rule: a year is a leap year if it is divisible by 4 but not by 100, or divisible by 400; February has 29 days in such years. The year conversion uses 365.25 days/year as an average that already compensates for leap years, so results are consistent across leap and non-leap years. The day difference is accumulated by actual calendar days, so leap years contribute one extra day.

FAQ

Why does the month conversion differ from actual calendar months?
The month conversion uses an average length of 30.4375 days as a uniform reference; actual calendar months range from 28 to 31 days, so "a few months" on the calendar may differ slightly from the converted value.
Does workday calculation include public holidays?
No. This tool only treats Monday through Friday as workdays and does not recognize public holidays or adjusted working days. For holiday-aware results, manually cross-check against the official holiday schedule.
Does date addition support fractional days?
No. This tool works in whole days only. For hour- or minute-level precision, please use a dedicated time calculator.

Note: Results are for reference only. For contracts, deadlines, and other formal scenarios, please refer to a professional calendar or legal regulations.

日期计算器说明

本工具支持两种日期运算:间隔计算求两个日期之间的天数及其折合年月周,日期加减在某个日期上增减天数得到结果日期,并可选择按工作日推算。所有计算在浏览器本地完成。

计算逻辑

  • 相差天数:将两个日期按本地时区 0 点对齐,取毫秒差除以 86400000(一天的毫秒数)并四舍五入,避免时区与夏令时带来的偏差。
  • 折合月数:按平均月长 30.4375 天折算(365.25 ÷ 12),结果保留两位小数。
  • 折合年数:按回归年 365.25 天折算(含闰年补偿),结果保留两位小数。
  • 包含周数:相差天数中包含的完整周数及剩余天数,如 364 天 = 52 周余 0 天。

工作日定义

开启「按工作日计算」后,日期加减将以周一至周五为有效工作日,跳过周六、周日。增减 N 个工作日表示从基准日期次日起(向前或向后)遇到的第 N 个工作日。本工具不计入法定节假日,如需精确到节假日请结合当年放假安排人工校验。

工作日推算:从基准日期次日开始按步长 1 遍历,遇周末跳过,累计满 |N| 个工作日即得结果

闰年说明

公历闰年规则:能被 4 整除且不能被 100 整除,或者能被 400 整除的年份为闰年,2 月有 29 天。折合年数采用 365.25 天/年已对闰年做平均补偿,故跨闰年与非闰年的折合结果一致。相差天数则按实际日历逐日累计,闰年会多出一天。

常见问题

为什么折合月数和实际日历月数不一样?
折合月数按平均月长 30.4375 天换算,是一个均匀化的参考值;实际日历中各月有 28 至 31 天不等,因此「几个月」在日历上对应的天数会与折合值略有出入。
工作日计算包含法定节假日吗?
不包含。本工具仅按周一至周五判断工作日,不识别春节、国庆等法定节假日及调休。如需考虑节假日,请结合国务院发布的放假安排人工核对。
日期加减支持小数天数吗?
不支持。本工具以整天为单位进行加减,如需精确到小时分钟请使用专门的时间计算工具。

说明:本工具计算结果仅供参考,涉及合同、期限等正式场景请以专业日历或法定规定为准。