Angelo Lee's Blog
This is my kingdom .If i don't fight for it ,who will ?

TimeZone Convert:

//要计算的区时=已知区时-(已知区时的时区-要计算区时的时区),(注:东时区为正,西时区为负)
//当算出的区时为负数时,应加上24:00,日期减一天
//当算出的区时大于或等于24:00时,应减去24:00,日期加一天

如果是在DateTimePicker中计算那么只要

DateTimePicker.Value.AddHours(-((curZoneHour + curZoneMin / 60) -
                (targetZoneHour + targetZoneMin / 60)));

但是前提是当前时区和目标时区的夏令时状态相同,即两者都同时使用夏令时或者都不在使用夏令时

如果当前时区用夏令时,目标时区没用夏令时,则

结果要-1小时

如果当前时区没用夏令时,目标时区用夏令时,则

结果要+1小时


通过PowerShell查看TimeZone:

How can I get this list programmatically with PowerShell?

$TimeZones = [TimeZoneInfo]::GetSystemTimeZones();
$TimeZones | Select-Object -Property "BaseUtcOffset", "StandardName", "DaylightName"


通过注册表查看TimeZone:

You can read all of the time zones in the registry, under the subkey

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Time Zones




posted on 2011-10-19 15:04  Angelo Lee  阅读(256)  评论(0编辑  收藏  举报