使用TimeZoneInfo代替TimeZone
概念
时间戳
时间戳就是当前时间距离1970年1月1日0点0时0分0秒(转换成北京时间是1970年1月1日8点0时0分0秒)距离你要计算的时间的秒数或者毫秒数。
总结:
TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970, 1, 1));
被
TimeZoneInfo.ConvertTime(new DateTime(1970, 1, 1), TimeZoneInfo.FindSystemTimeZoneById("China Standard Time"));
常用时区表

| 国家 | 代码 | 时区ID | 标准名称 |
|---|---|---|---|
| 美国 | US | Pacific Standard Time | 太平洋标准时间 |
| 英国 | GB | GMT Standard Time | GMT 标准时间 |
| 德国 | DE | W. Europe Standard Time | 西欧标准时间 |
| 法国 | FR | Romance Standard Time | 罗马标准时间 |
| 日本 | JP | Tokyo Standard Time | 东京标准时间 |
| 意大利 | IT | W. Europe Standard Time | 西欧标准时间 |
| 西班牙 | ES | Romance Standard Time | 罗马标准时间 |
| 加拿大 | CA | Pacific Standard Time | 太平洋标准时间 |
| 墨西哥 | MX | Central Standard Time (Mexico) | 中部标准时间(墨西哥) |
| 中国 | CN | China Standard Time | 中国标准时间 |
| 澳大利亚 | AU | E. Australia Standard Time | 东部澳大利亚标准时间 |
全部时区表
更新时间:2024.2.14
链接
本文来自博客园,作者:星空探险家,转载请注明原文链接:https://www.cnblogs.com/PuppetLazy/p/18015535

浙公网安备 33010602011771号