TZ
版本历史
| 版本 | 变更 |
|---|---|
| v16.2.0 | 使用 process.env.TZ = 更改 TZ 变量也会更改 Windows 上的时区。 |
| v13.0.0 | 使用 process.env.TZ 更改 TZ 变量 = 更改 POSIX 系统上的时区。 |
| v0.0.1 | 新增于: v0.0.1 |
TZ 环境变量用于指定时区配置。
\The TZ environment variable is used to specify the timezone configuration.
虽然 Node.js 不支持所有各种 TZ 在其他环境中的处理方式,但它支持基本的 时区 ID(例如 'Etc/UTC'、'Europe/Paris' 或 'America/New_York')。它可能支持其他一些缩写或别名,但强烈建议不要使用这些缩写或别名,并且不能保证。
\While Node.js does not support all of the various ways that TZ is handled in
other environments, it does support basic timezone IDs (such as
'Etc/UTC', 'Europe/Paris', or 'America/New_York').
It may support a few other abbreviations or aliases, but these are strongly
discouraged and not guaranteed.
$ TZ=Europe/Dublin node -pe "new Date().toString()"
Wed May 12 2021 20:30:48 GMT+0100 (Irish Standard Time)