📅 Date Duration Calculator

Enter two dates to compute the exact number of days and weeks between them, with inclusive or exclusive end-date options. Runs locally.

📐 工作原理与说明
日期天数差计算
原始差值(天) = round[(日期2 − 日期1) ÷ 86400000](毫秒→天,按日历日计算)
含当天模式:天数 = 原始差值 + 1(起止两天都计入)
周数 = 天数 ÷ 7
输入格式:YYYY-MM-DD
计算两个日期之间相差的天数。
  • 原理:把日期转为时间戳(或儒略日数)后相减,再除以 86400000 ms 得天数。
  • 口径:是否包含起始日会影响结果,需明确“相差天数”与“间隔夜数”的定义。
  • 时区:按本地时区还是 UTC 计算会改变结果;跨夏令时的地区尤其需要注意。
  • 闰年:能被 4 整除且不被 100 整除,或能被 400 整除的年份为闰年。

Formula & Standard References

Item Formula / Note Source / Standard
Duration format ISO 8601: PnYnMnDTnHnMnS ISO 8601; RFC 3339
⚠️ 使用说明与注意事项

📋 示例

起止天数(不含末)
2026-01-012026-01-021
2026-01-012026-02-0131
2026-08-012026-08-2423