时区转换工具

将任意时间字符串转换为 UTC 及多个目标时区。支持 ISO 8601、UTC 偏移表示法和常见日期格式。

使用方法

  1. Paste or type a time string in any common format (e.g. 2024-01-15 14:30:00 UTC+8)
  2. Click 'Parse & Convert' — the tool detects the timezone offset from the string
  3. The UTC+0 equivalent is displayed at the top
  4. Use the preset buttons or enter a custom UTC offset to add target timezones
  5. Remove any timezone row by clicking the ✕ button

常见问题

  • What time formats are supported?

    ISO 8601 (2024-01-15T14:30:00+08:00), space-separated datetime (2024-01-15 14:30:00 UTC+8), RFC 2822, and many locale date strings. The tool also recognises UTC and GMT prefix notation.

  • What if the string has no timezone info?

    The tool parses the date and time as-is. If no offset is found in the string, the time is treated as UTC+0. Make sure to include a UTC offset like +08:00 or UTC+8 for accurate conversion.

  • Can I add multiple target timezones?

    Yes. Use the preset buttons for common zones (UTC+0 through UTC+10, UTC-5/6/8), or type any offset from -12 to +14 in the input box and press the + button.

  • Are half-hour and quarter-hour offsets supported?

    Yes. Offsets like UTC+5:30 (India), UTC+5:45 (Nepal), and UTC+9:30 (Australia Central) are all supported. Enter 5.5 in the offset input for UTC+5:30.

  • Does the tool work offline?

    Yes — all conversions happen entirely in your browser using JavaScript. No data is sent to any server.

时区转换为什么这么难?

表面上,时区转换只是加减一个小时数,似乎很简单。但现实中,时区问题是程序员最容易踩坑的领域之一,原因在于这几个复杂因素:

夏令时(DST):美国、欧洲等地区每年会调整一次时钟,导致某个时区的 UTC 偏移量在一年中会变化。例如,纽约在冬季是 UTC-5(EST),夏季是 UTC-4(EDT)。直接用固定偏移量计算,在夏令时切换前后就会出现一小时的误差。

非整点时区:大多数时区与 UTC 相差整数小时,但也有例外:印度是 UTC+5:30,尼泊尔是 UTC+5:45,澳大利亚中部是 UTC+9:30,伊朗是 UTC+3:30。这些"半小时"和"十五分钟"时区经常被简化处理导致出错。

时区名称歧义:缩写如 "CST" 可以指中国标准时间(UTC+8)、美国中部标准时间(UTC-6)或古巴标准时间(UTC-5)。依赖时区名称缩写做转换极不可靠。

UTC 的核心地位

UTC(协调世界时)是全球时间系统的基准,不受任何地区的夏令时影响。在技术系统中,有一条重要原则:内部存储和传输时间时,始终使用 UTC;仅在展示给用户时,才转换为本地时间。

这个原则能避免大量时区相关的 bug,尤其在涉及跨时区用户的日志系统、定时任务和事件追踪场景中至关重要。

ISO 8601 标准格式

ISO 8601 是国际标准化组织制定的日期时间表示规范,推荐格式为:

2024-01-15T14:30:00+08:00

这个格式将日期、时间和时区偏移量合并在一个字符串中,消除了歧义。后缀 Z 等价于 +00:00,表示 UTC 时间。API 设计、日志记录、数据交换中应尽量使用 ISO 8601 格式,而非"2024/1/15 下午 2:30"这类依赖地区习惯的格式。