简体   繁体   English

如何在Windows 10上更改TimeZone?

[英]How to change the TimeZone on Windows 10?

I'm creating a python program to change the timezone of my computer (permanently, or until it is changed again) on windows 10. The current program I currently have changes the time zone, but I am specifically trying to change the time zone to (UTC) Coordinated Universal Time and I'm having trouble understanding some of the parameters of the function im using (and changing the timezone to UTC) 我正在创建一个python程序来更改Windows 10上我的计算机的时区(永久或直到再次更改)。当前的程序我当前已更改了时区,但是我正在专门尝试将时区更改为(UTC)协调世界时,我无法理解im正在使用的功能的某些参数(并将时区更改为UTC)

I was unable to find the UTC timezone on this Microsoft Docs page about TimeZones. 我无法在此Microsoft Docs页面上找到有关TimeZones的UTC时区。

def changeTimeZone():
    win32api.SetTimeZoneInformation((-600, u'Coordinated Universal Time',
                                    (2000, 4, 1, 3, 0, 0, 0, 0), 0,
                                     u'Coordinated Universal Time',
                                    (2000, 10, 1, 2, 0, 0, 0, 0), -60))

It changes the time, but I am unsure if it changes permanently, It also does not change the time to UTC. 它会更改时间,但是我不确定是否会永久更改,也不会更改UTC时间。 Checking the windows time zone says it appears to be switched to UTC, however when i manually set it to UTC instead of using the python program, the times are different. 检查Windows时区表示它似乎已切换为UTC,但是当我手动将其设置为UTC而不是使用python程序时,时间是不同的。

Changing all paramters of the function to 0, adjusted the time to be the correct one. 将函数的所有参数更改为0,将时间调整为正确的时间。

def changeTimeZone():
    #win32api.SetTimeZoneInformation((-600, u'Coordinated Universal Time', (2000, 4, 1, 
#3, 0, 0, 0, 0), 0,
                                     #u'Coordinated Universal Time', (2000, 10, 1, 2, 
#0, 0, 0, 0), -60))

    win32api.SetTimeZoneInformation((0, u'Coordinated Universal Time', (0, 0, 0, 0, 0, 
0, 0, 0), 0,
                                     u'Coordinated Universal Time', (0, 0, 0, 0, 0, 0, 
0, 0), 0))

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM