Tool Hub

相對時間

測試 Intl.RelativeTimeFormat 的相對時間輸出 (如 '2 天前')

從時間戳或日期產生人類可讀的相對時間字串(例如"3小時前"、"2天後")。適用於預覽timeago風格標籤在不同地區和時間位移下的渲染效果。

Locale結果
en-US3 days ago
en-GB3 days ago
zh-CN3天前
zh-TW3 天前
es-EShace 3 días
hi-IN3 दिन पहले
pt-BRhá 3 dias
fr-FRil y a 3 jours
de-DEvor 3 Tagen
ja-JP3 日前
ko-KR3일 전

使用方法

  1. Enter a numeric value in the value field; negative numbers mean the past, positive numbers mean the future。
  2. Select a time unit from the dropdown: second, minute, hour, day, week, month, quarter, or year。
  3. Read the table to compare how Intl.RelativeTimeFormat renders the duration across 11 locales。
  4. Note that the 'auto' style returns natural-language phrases like 'yesterday' or 'last month' when applicable。

範例

  • Entering -1 with unit 'day' shows 'yesterday' in en-US, 'hier' in fr-FR, and '어제' in ko-KR。
  • Entering 3 with unit 'month' shows 'in 3 months' in en-US and corresponding translations across all 11 locales。

生產環境使用前請驗證輸出。無擔保 — 參見 條款.