什么是时区转换?
时区转换器将某一时区的日期和时间转换为另一时区的对应时间,让您即时查看全球任意地点的等效时刻。全球划分为 24 个主要时区,每个时区定义为相对协调世界时(UTC)的固定偏移量。当 UTC 时间为 14:00 时,纽约时间为 09:00(UTC-5),东京时间为 23:00(UTC+9)。正确进行时区转换需要知道源时区和目标时区各自的 UTC 偏移量,以及两者是否正处于夏令时(DST)期间。
IANA 时区数据库(常称为 Olson 数据库或 tz 数据库)是操作系统、编程语言和网页浏览器所使用的时区定义标准来源。它为每个时区分配一个格式为"地区/城市"的规范标识符,例如 America/New_York 或 Asia/Tokyo。与 EST、PST 等固定缩写不同,IANA 标识符完整记录了每个地区 UTC 偏移量变更和 DST 转换的全部历史,是在过去或未来任意日期进行跨时区转换的唯一可靠方式。
本时区转换器使用浏览器 JavaScript 引擎通过 Intl API 内置的 IANA 时区数据。您选择源时区,输入日期和时间,工具立即计算出目标时区的等效时间,包含夏令时调整。由于完全在浏览器中运行,无需服务器往返,数据不会离开您的设备。
为什么使用这个时区转换器?
手动计算时区容易出错,尤其是涉及夏令时时。一座城市 1 月份可能是 UTC-5,而 7 月份变为 UTC-4,且各国时钟拨快拨慢的日期各不相同。美国和欧洲在不同的周日更换时间,由此产生约两周的时间窗口,在此期间纽约与伦敦之间的偏移量与全年其他时段不同。本工具使用与您的操作系统相同的 IANA 数据库,自动处理所有这些转换。
时区转换器使用场景
IANA 时区参考表
IANA 时区数据库定义了 400 余个时区标识符,并每年更新数次以反映政治变化、新的 DST 规则和历史修正。下表列出了最常用的时区及其标准 UTC 偏移量和 DST 行为。所示偏移量为标准时间偏移量;DST 列显示该地区夏令时生效时的调整后偏移量。
| IANA 标识符 | 常用名称 | UTC 偏移量 | DST |
|---|---|---|---|
| UTC | Coordinated Universal Time | +00:00 | No |
| America/New_York | Eastern Time (US) | -05:00 | Yes (EDT -04:00) |
| America/Chicago | Central Time (US) | -06:00 | Yes (CDT -05:00) |
| America/Denver | Mountain Time (US) | -07:00 | Yes (MDT -06:00) |
| America/Los_Angeles | Pacific Time (US) | -08:00 | Yes (PDT -07:00) |
| Europe/London | Greenwich Mean Time | +00:00 | Yes (BST +01:00) |
| Europe/Berlin | Central European Time | +01:00 | Yes (CEST +02:00) |
| Europe/Moscow | Moscow Time | +03:00 | No |
| Asia/Dubai | Gulf Standard Time | +04:00 | No |
| Asia/Kolkata | India Standard Time | +05:30 | No |
| Asia/Shanghai | China Standard Time | +08:00 | No |
| Asia/Tokyo | Japan Standard Time | +09:00 | No |
| Australia/Sydney | Australian Eastern Time | +10:00 | Yes (AEDT +11:00) |
| Pacific/Auckland | New Zealand Standard Time | +12:00 | Yes (NZDT +13:00) |
代码示例
主流编程语言均通过 IANA 数据库提供时区转换功能。以下示例展示如何在 JavaScript 中使用 Intl API、Python 中使用 zoneinfo 模块、Go 中使用 time 包,以及在 Shell 脚本中使用 GNU date 命令,将 UTC 时间戳转换为其他时区。
// Convert a date from one timezone to another
const date = new Date('2026-03-15T09:00:00Z')
// Format in specific timezone
const nyTime = date.toLocaleString('en-US', { timeZone: 'America/New_York' })
// → "3/15/2026, 5:00:00 AM"
const tokyoTime = date.toLocaleString('en-US', { timeZone: 'Asia/Tokyo' })
// → "3/15/2026, 6:00:00 PM"
// Get the UTC offset for a timezone programmatically
function getUtcOffset(tz: string, date = new Date()) {
const fmt = new Intl.DateTimeFormat('en-US', {
timeZone: tz,
timeZoneName: 'longOffset',
})
const parts = fmt.formatToParts(date)
return parts.find(p => p.type === 'timeZoneName')?.value ?? ''
}
getUtcOffset('Asia/Kolkata') // → "GMT+05:30"from datetime import datetime
from zoneinfo import ZoneInfo
# Create a timezone-aware datetime
dt = datetime(2026, 3, 15, 9, 0, tzinfo=ZoneInfo('UTC'))
# Convert to New York time
ny = dt.astimezone(ZoneInfo('America/New_York'))
print(ny) # → 2026-03-15 05:00:00-04:00 (EDT in March)
# Convert to Tokyo time
tokyo = dt.astimezone(ZoneInfo('Asia/Tokyo'))
print(tokyo) # → 2026-03-15 18:00:00+09:00
# Get current time in any timezone
now_berlin = datetime.now(ZoneInfo('Europe/Berlin'))
print(now_berlin.strftime('%Y-%m-%d %H:%M %Z')) # → 2026-03-15 10:00 CETpackage main
import (
"fmt"
"time"
)
func main() {
utc := time.Date(2026, 3, 15, 9, 0, 0, 0, time.UTC)
// Load timezone by IANA name
ny, _ := time.LoadLocation("America/New_York")
tokyo, _ := time.LoadLocation("Asia/Tokyo")
fmt.Println(utc.In(ny)) // → 2026-03-15 05:00:00 -0400 EDT
fmt.Println(utc.In(tokyo)) // → 2026-03-15 18:00:00 +0900 JST
// Get the UTC offset in seconds
_, offset := utc.In(ny).Zone()
fmt.Printf("UTC offset: %+d hours\n", offset/3600) // → UTC offset: -4 hours
}# Display current time in a specific timezone TZ='Asia/Tokyo' date '+%Y-%m-%d %H:%M:%S %Z' # → 2026-03-15 18:00:00 JST # Convert a UTC timestamp to another timezone TZ='America/Los_Angeles' date -d '2026-03-15T09:00:00Z' '+%Y-%m-%d %H:%M %Z' # → 2026-03-15 02:00 PDT # List all available IANA timezone names timedatectl list-timezones | head -20