📅 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 整除的年份為閏年。
  • 年份範圍:支援公曆 0001–9999 年,按 proleptic Gregorian 歷逐段推算(不經過瀏覽器 Date 的兩位年偏移);民國紀、西元前等非公曆紀年請先換算為公曆年。

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