Sign in to follow this  
Followers 0
ravenfyre

Getting Gmt (greenwich Mean Time)

6 posts in this topic

#1 ·  Posted (edited)

I'm working on a clock script and I'm almost done. The clock has to be in GMT, since my clock is PST that's an -8 hour timezone offset. Sure I can just add 8 hours to my script but I wouldn't be a very good script writer if I would lol.

How can I make the script detect the timezone offset? If I can make it do that, then it can just subtract it from the @Hour macro to get the GMT. I was thinking the registry but no luck with that, found the options but not the timezone currently selected.

Edited by ravenfyre

Share this post


Link to post
Share on other sites



reg is held I think in:

My Computer\HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\TimeZoneInformation

This will give you the current timezone, and if you want to cross referance with the keys in:

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

that should get you started. Or you could get a net time.


AutoIt3, the MACGYVER Pocket Knife for computers.

Share this post


Link to post
Share on other sites

Hmm guess that would work but it's not really an easy fix since the key list is so long, unless I could actually search the keys My Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Time Zones for the current timezone. No registry search function, guess it's time to write my own :whistle:. Still before I get cracking on this, are there any other ways to get the current timezone?

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Some OS's set an environment variable TZ with the time zone information.

PST8PDT The default is PST (Pacific Standard Time), which is 8 hours after GMT (If it is 12 noon in PST, it is 8 pm UCT). Daylight savings is known as PDT, which is one hour ahead.

CST7 Saskatchuwan - The default is CST (Central Standard Time), which is 7 hours after GMT. There is no daylight savings time.

Does that help?

Edited by Nutster

David Nuttall
Nuttall Computer Consulting

An Aquarius born during the Age of Aquarius

AutoIt allows me to re-invent the wheel so much faster.

I'm off to write a wizard, a wonderful wizard of odd...

Share this post


Link to post
Share on other sites

Sorry I thought you would figure it out, but here is the WinXp,2000,NT version:

$x=RegRead ( "HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\TimeZoneInformation","StandardName")
$GMT=RegRead ( "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Time Zones\"&$x,"Display")
$GMT2=StringMid($gmt,5,3)
msgbox(1,"Timezone="&$x, "GMT="&$GMT & @crlf & $gmt2 &" Hour adj")

AutoIt3, the MACGYVER Pocket Knife for computers.

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Sorry I thought you would figure it out, but here is the WinXp,2000,NT version:

$x=RegRead ( "HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\TimeZoneInformation","StandardName")
$GMT=RegRead ( "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Time Zones\"&$x,"Display")
$GMT2=StringMid($gmt,5,3)
msgbox(1,"Timezone="&$x, "GMT="&$GMT & @crlf & $gmt2 &" Hour adj")
Impressive, I would have never figured it out using this method :whistle: . Never knew about stringmid, will come in handy next time I'll tinker with the registry. Thanks scriptkitty. Edited by ravenfyre

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0