Intermediate

從日期加減時間

從起始日期時間加減任意組合的年、月、週、天、時、分和秒,以求得結果時刻。
ISO format, e.g. 2026-06-27T09:00

yr

mo

wk

h

分鐘

s

Resulting date and time
2027-09-06 15:30:00
星期幾
Monday
Starting date-time
2026-06-27 09:00:00
Total day shift
436.27 天
Total second shift
37,693,800 seconds
2026-06-27 09:00:002027-09-06 15:30:00436.27 天Time span from starting date-time to result
計算結果僅為一般資訊用途的估算值,並非專業建議——在仰賴重要結果之前,請務必自行獨立查證。 閱讀完整免責聲明.
快速解答

此計算機如何運作?

輸入基礎日期時間及帶正負號的年、月、週、天、時、分、秒偏移量。工具先以日曆調整年月部分,再以固定毫秒跨度加總其餘部分,返回結果日期時間、星期及總偏移天數和秒數。

公式
result = base, then setFullYear(+Δy), setMonth(+Δmo), then + ((Δd + 7·Δw)·86400 + 3600·Δh + 60·Δmi + Δs)·1000 ms
How this is calculated

以ISO格式(例如2026-06-27T09:00)輸入基礎日期時間。每個偏移欄位接受正數(加時間)或負數(減時間)。計算分兩個階段套用偏移量,以符合日常日曆的預期。

首先套用日曆部分:年偏移以setFullYear套用,月偏移以setMonth套用。這兩者考慮月份長度不等和閏年,因此「一個月」會盡量落在同一日(JavaScript Date會處理月末溢位的正規化)。之後,週、天、時、分、秒等已過時間部分轉換為單一毫秒跨度,公式為(Δd + 7·Δw)·86400 + 3600·Δh + 60·Δmi + Δs,乘以1000後加至日期。

輸出顯示結果日期時間、星期,以及以天數和秒數表示的總偏移量(最終時刻與起始時刻之差)。請注意,總天數和總秒數以本地時間軸計算,因此本地時區的日光節約時間切換可能使已過秒數與名義偏移量略有差異。

常見問題

在任意偏移欄位中輸入負數。例如在「天」欄位輸入-3,即可往前推三天。正負偏移量可自由混合使用。

月份長度不同,工具調整的是日曆月份而非固定的30天。1月31日加一個月會落在3月初,因為2月天數較少,這是標準日曆行為。

年和月先作為日曆調整套用,再以固定已過時間跨度加入週、天、時、分、秒。此順序使月末和閏年結果更符合直覺。

也稱為

日期加減時間
日期加時間
日期減時間
日期加小時
時間計算
日期運算
加減時間
日期時間計算

APA

TG we-Calculate Editorial Team. (2026). 從日期加減時間 [Online calculator]. TG we-Calculate. https://we-calculate.com/zh-tw/calculator/add-subtract-time

Chicago

TG we-Calculate Editorial Team. "從日期加減時間." TG we-Calculate. 2026. https://we-calculate.com/zh-tw/calculator/add-subtract-time.

IEEE

TG we-Calculate Editorial Team, "從日期加減時間," TG we-Calculate, 2026. [Online]. Available: https://we-calculate.com/zh-tw/calculator/add-subtract-time

BibTeX

@misc{wecalculate_add_subtract_time, title = {從日期加減時間}, author = {{TG we-Calculate Editorial Team}}, howpublished = {\url{https://we-calculate.com/zh-tw/calculator/add-subtract-time}}, year = {2026}, note = {TG we-Calculate} }

這個計算機對您有幫助嗎?