Retrieving the Offset (time zone) set up at the computer.

Question:

How can I retrieve the Offset set up at the computer so that I can calculate the time according to UTC/GMT?

Solution:

Via VBScript, you can retrieve the Offset value set up at Windows Registry.

Example:

DateTime = now()
set Shell = CreateObject(“WScript.Shell”)
atb = “HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\TimeZoneInformation\ActiveTimeBias”
offsetMin = Shell.RegRead(atb)
msgbox “Offset in Minutes = ” & offsetMin
UTC = DateAdd(“n”, offsetMin, DateTime) ‘Adds Offset to current DateTime
msgbox “Current = ” & DateTime & ” — UTC = ” & UTC
Print Friendly, PDF & Email

Este artigo foi útil? Was this helpful?

Classificação média - Average rating 0 / 5. Count: 0

Leave a Reply

Your email address will not be published.Required fields are marked *