日期计算
Auto-calculate on date input 输入日期自动计算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.
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
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 个工作日。本工具不计入法定节假日,如需精确到节假日请结合当年放假安排人工校验。
闰年说明
公历闰年规则:能被 4 整除且不能被 100 整除,或者能被 400 整除的年份为闰年,2 月有 29 天。折合年数采用 365.25 天/年已对闰年做平均补偿,故跨闰年与非闰年的折合结果一致。相差天数则按实际日历逐日累计,闰年会多出一天。
常见问题
说明:本工具计算结果仅供参考,涉及合同、期限等正式场景请以专业日历或法定规定为准。