问题
SET TZ=AEST -9
"c:\Program Files (x86)\Mozilla Firefox\firefox.exe"
Test against: https://whoer.net/ . Notice how it displays AES and not AEST and the -9 does not get recognized.
Not really sure if there is a workaround for this and the fact you can change your OS time through your browser is amazing. But thought I'd ask, has anyone gotten around this issue?
If I put in UTC -9 that would work but I'm testing for words above 3 letters.
回答1:
A few things:
- The
TZvariable must meet the POSIX time zone specification, of the first or second formats described here. The space in your string makes the identifier invalid. AESTis typically used for Australian Eastern Standard Time, which is UTC+10, not UTC+9.- As the POSIX form has the sign inverted, you would use
AEST-10if you intended to represent the time in Queensland that is UTC+10 year-round. If you meant to represent NSW (Sydney, etc.), then you need a much more complex identifier to represent the current time zone rules:
AEST-10AEDT,M10.1.0,M4.1.0/3In general, POSIX time zone strings should not be used in most cases. They are insufficient to work with all the time zones of the world, as they cannot represent historical changes or more than two transitions in a year. This is also discussed in the timezone tag wiki.
- As the POSIX form has the sign inverted, you would use
Ideally, you'd use the third format of the
TZvariable, which is an IANA tzdb identifier, such asAustralia/BrisbaneorAustralia/Sydney, however this will not work on Windows OS. You can only use this for Linux, OSX, etc.In general, setting the
TZvariable on Windows isn't reliable, as only certain APIs will use it at all. For example, the Windows C Run-Time Library's localtime function will useTZvariable, but the Win32 API's GetTimeZoneInformation function will not. Since one generally has no idea what the internals of the application are doing, it's not reasonable to expect theTZvariable to function in all cases. Indeed, while FireFox currently works, it may stop working with it in some future release - and it doesn't work for other browsers like Chrome and Edge.There currently is no reliable way to set the time zone for a single process on Windows.
来源:https://stackoverflow.com/questions/45253162/set-browser-time-zone-more-than-four-letters