Re: Reading Time zone offset
- From: "Richard Mueller [MVP]" <rlmueller-NOSPAM@xxxxxxxxxxxxxxxxxxxx>
- Date: Wed, 31 Jan 2007 07:23:44 -0600
"Youri Ligotmi" <yl@xxxxxxxxxxxxxxx> wrote in message
news:45bf9f87$0$29486$426a34cc@xxxxxxxxxxxxxxx
Youri Ligotmi a écrit :_
Richard Mueller [MVP] a écrit :
Phil wrote:
In a script I need to know the time zone offset of the computer the
script is running on, something like +0100 or -1300 etc
How can I get this information?
Thanks for your help
I use the following snippet:
========
' Obtain local Time Zone bias from machine registry.
Set objShell = CreateObject("Wscript.Shell")
lngBiasKey = objShell.RegRead("HKLM\System\CurrentControlSet\Control\"
with& "TimeZoneInformation\ActiveTimeBias")
If (UCase(TypeName(lngBiasKey)) = "LONG") Then
lngBias = lngBiasKey
ElseIf (UCase(TypeName(lngBiasKey)) = "VARIANT()") Then
lngBias = 0
For k = 0 To UBound(lngBiasKey)
lngBias = lngBias + (lngBiasKey(k) * 256^k)
Next
End If
=======
This was designed to work on any 32-bit client, which is why I test
I got the answer! he time is in minutes and the offset is from *my*TypeName. The result (lngBias) is in minutes.Thanks for your help. My computer is set on GMT +1 but when I run your
script I get -60 for lngBias.
Do you have some more informations on the ActiveTimeBias value?
regards
Phil
location to greenwich, so from greenwich to *my* location I have to take
the opposite.
Thanks again Richard
Yes. I'm on GMT+6 (Central Time US) and my bias is 360. You subtract the
bias value (lngBias in minutes) from the UTC date/time value to convert to
local time. Note that during daylight savings, this value changes. For me,
lngBias is 300 during daylight savings. This makes the conversion from UTC
to local time correct. If you don't what the daylight savings adjustment,
then use Bias rather than ActiveTimeBias in the registry.
--
Richard
Microsoft MVP Scripting and ADSI
Hilltop Lab web site - http://www.rlmueller.net
--
.
- References:
- Reading Time zone offset
- From: Youri Ligotmi
- Re: Reading Time zone offset
- From: Richard Mueller [MVP]
- Re: Reading Time zone offset
- From: Youri Ligotmi
- Re: Reading Time zone offset
- From: Youri Ligotmi
- Reading Time zone offset
- Prev by Date: Error 70 and error 424 trying to use Navigate2 or Shell.Application.Windows
- Next by Date: How to copy an object in a array?
- Previous by thread: Re: Reading Time zone offset
- Next by thread: executing a script from a vbscript program, and getting results
- Index(es):
Relevant Pages
|