📅 Date Difference Calculator (Y/M/W/D)
📐 计算公式 / 原理
天数 = 两日期差 + 1(含起始日);工作日 = 天数 − 落在周六/周日的天数
先交换保证起始 ≤ 结束;未勾选「包含开始日」时起始日 +1 天。天数为日历差加 1;勾选「包含周末」时按自然日计数,否则扣减落在周六周日的天数得工作日。周数按 7 天一周;年月与总月数为「完整日历月」(按月末夹取逐月推进,未满一月不计),与是否排除周末无关。
--
--
📋 计算历史
暂无历史记录
📖 使用说明
• 日期差计算:计算两个日期之间相差的天数、周数、月数、年数
• 工作日计算:取消勾选"包含周末"可计算工作日数量
• 日期加减:在指定日期上加上或减去年、月、周、天
• 节日倒计时:查看距离各节日还有多少天
• 历史记录自动保存在本地,最多保存50条
📚 深度解析:日期差计算器
💡 常见使用场景
- 与 date-diff 同,算间隔。
- 算两次体检、两次续费之间的间隔,判断是否超过周期要求。
计算
2025-12-25 到 2026-01-01:勾选「包含开始日」为 8 天;取消勾选为 7 天。
❓ 常见问题(FAQ)
- 跨年?
- 自动处理闰年与跨年。
- 含开始日和不含差几天?
- 勾选「包含开始日」结果 +1 天:同一天起止含开始日记为 1 天,不含则记为 0 天。
Formula & Standard References
| Item | Formula / Note | Source / Standard |
|---|---|---|
| Borrowing method | subtract per field and borrow the actual length of the month | Calendar arithmetic |
| Month-end alignment | when both dates end a month subtract month counts directly | Calendar arithmetic |
| Time zone effect | pure date differences ignore zones while time-bearing ones do not | ISO 8601-1 |
⚠️ 使用说明与注意事项
- 本工具纯前端运行,数据不会上传到服务器
- 建议在主流浏览器(Chrome/Safari/Firefox/Edge)中使用
- 计算结果仅供参考,请以实际应用场景为准