Sign in to follow this  
Followers 0
WeMartiansAreFriendly

retrieve computers timezone e.g. -0800 GMT

1 post in this topic

Ok so I want to know how I can get the computers timezone information for example -0800 GMT, that would be hours '-08' and '00' seconds and GMT..

I found information from this topic and I came up with the function below.

Ok, good problem solved? no. I doubt the functions accuracy and speed, As a fact it's rather ugly and a big stupid head.

Can someone help a brother out who can't seem to find a better solution.

Func _GetTimeZone($sFormat = "%+.2d%.2d")
    Local $avArray[6]

    $standardName = RegRead("HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\TimeZoneInformation", "StandardName")
    $zoneInfo = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Time Zones\" & $standardName, "Display")
    ;MsgBox(0, '', $standardName)
    $abrv = ""
    For $i = 1 to StringLen($standardName)
        $s = StringMid($standardName, $i, 1)
        If StringIsUpper($s) Then $abrv &= $s
    Next
;disregard this part

    $sString = StringTrimLeft($zoneInfo, 1) ;trim off "("
    $sString = StringLeft($sString, StringInStr($sString, ")")-1) ;trim off everything after ")"

    $sZone = StringLeft($sString, 3)        ; zone
    $sOffset = StringTrimLeft($sString, 3)  ; offset
    $sHR = StringLeft($sOffset, StringInStr($sOffset, ":")-1) ;get hour
    $sMN = StringRight($sOffset, StringLen($sHR)-1) ;get second
    $sOffset = StringFormat($sFormat, $sHR, $sMN) ;format
    
    ;$avArray[0] = $zoneInfo
    $avArray[1] = $sZone
    $avArray[2] = $sOffset
    $avArray[3] = $abrv
    
    Return $avArray
EndFunc

Don't bother, It's inside your monitor!------GUISetOnEvent should behave more like HotKeySet()

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