Travel Days Counter
Travel Days Counter
📐 工作原理與說明
行程天數 =(返回日期 − 出發日期)÷ 86400000 + 1(含首尾兩天);住宿晚數 = 天數 − 1;距出發倒計時 =(出發日期 − 當前日期)向上取整;跨月跨年按時間戳自動累計,閏年 2 月多計 1 天;已過天數 = 當前日期 − 出發日期。
📚 深度解析:旅行天數/倒計時
💡 常見使用場景
- 行程跨度
- 出發倒計時
- 已過天數
9/1–9/7
days=ceil((9/7−9/1)/86400000)+1=7 天、nights=6、hours=168、weeks=1;含首尾算 7 天。
未來出發倒計時
start 設 9/10、now 9/1,untilStart=ceil((start−now)/86400000)=9 天;用於_plan 行前準備。
❓ 常見問題(FAQ)
- 天數含首尾嗎?
- 含,end−start 毫秒加 1 天;nights=days−1 為過夜數。
- 倒計時負了?
- start 已過則 sinceEnd 為正,表示行程已結束多少天。
Formula & Standard References
| Item | Formula | Source-Standard |
|---|---|---|
| Day counting | Travel days are counted as calendar days including both endpoints | ISO 8601-1:2019 Date and time - Representations for information interchange - Part 1: Basic rules |
| Interval notation | Intervals are written as start date slash end date | ISO 8601-1:2019 Date and time - Representations for information interchange - Part 1: Basic rules |
| Month crossing | Intervals crossing months sum the actual days of each month | ISO 8601-1:2019 Date and time - Representations for information interchange - Part 1: Basic rules |
⚠️ 使用說明與注意事項
- 本工具純前端執行,資料不會上傳到伺服器
- 建議在主流瀏覽器(Chrome/Safari/Firefox/Edge)中使用
- 計算結果僅供參考,請以實際應用場景為準