Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

time zone

2 views
Skip to first unread message

Jay [Work]

unread,
May 8, 2003, 12:19:06 PM5/8/03
to
How can I change the time zone with a script? or is there a free util out
there I can pass parameters to make the change?

thanks
Jay


Robert Cohen

unread,
May 8, 2003, 6:26:48 PM5/8/03
to
there is a lot on google on how to do it. This is one of about 12000
scripts there with a search of vbscript time zone:

'**************************************
' Name: GetLocalTZ
' Description:Compute the local time zon
' e in minutes from GMT, agjusting for Day
' light Saving Time (DST), find the local
' time zone name
' By: Dror Saddan
'
' Inputs:An optional string which will h
' old the time zone name.
'
' Returns:The local time zone in minutes
' , the time zone name.
'
' Assumes:The time zone information is s
' et correctly.
'
' Side Effects:None.
'
'This code is copyrighted and has' limited warranties.Please see http://w
' ww.Planet-Source-Code.com/xq/ASP/txtCode
' Id.844/lngWId.1/qx/vb/scripts/ShowCode.h
' tm'for details.'**************************************

'***************************************
' *****************************
'* Returns the machine TZ as minutes fro
' m GMT
'* If the TZ is PST which is GMT-8 you w
' ill get -28880
'* The TZ is adjusted for DST
'* The name of the TZ is returned in the
' parameter strTZName
'* Written by Dror Saddan (drors@ietusa.
' com)
'* Date: April 4,1998
'***************************************
' *****************************


Function GetLocalTZ(Optional ByRef strTZName As String) As Long
Dim objTimeZone As TIME_ZONE_INFORMATION
Dim lngResult As Long
Dim i As Long
lngResult = GetTimeZoneInformation&(objTimeZone)


Select Case lngResult
Case 0&, 1&'use standard time
GetLocalTZ = -(objTimeZone.Bias + objTimeZone.StandardBias) *
60'into minutes


For i = 0 To 31
If objTimeZone.StandardName(i) = 0 Then Exit For
strTZName = strTZName & Chr(objTimeZone.StandardName(i))
Next
Case 2& 'use daylight savings time
GetLocalTZ = -(objTimeZone.Bias + objTimeZone.DaylightBias) * 60
'into minutes


For i = 0 To 31
If objTimeZone.DaylightName(i) = 0 Then Exit For
strTZName = strTZName & Chr(objTimeZone.DaylightName(i))
Next
End Select
End Function


Function TestTimeZone()
Dim strTZ As String
Debug.Print GetLocalTZ(strTZ)
Debug.Print strTZ
End Function


"Jay [Work]" <nos...@nospam.com> wrote in message
news:eD2yN2XF...@TK2MSFTNGP12.phx.gbl...

Torgeir Bakken (MVP)

unread,
May 8, 2003, 8:40:49 PM5/8/03
to
"Jay [Work]" wrote:

> How can I change the time zone with a script? or is there a free util out
> there I can pass parameters to make the change?

Hi

From command lie (Win2k/WinXP):

Control.exe TIMEDATE.CPL,,/Z (GMT-08:00) Pacific Time (US & Canada); Tijuana

alternatively:
RUNDLL32.EXE SHELL32.DLL,Control_RunDLL TIMEDATE.CPL,,/Z (GMT-08:00) Pacific
Time (US & Canada); Tijuana

where '(GMT-08:00) Pacific Time (US & Canada); Tijuana' is the timezone to be
set.


--
torgeir
Microsoft MVP Scripting and WMI, Porsgrunn Norway
Administration scripting examples and an ONLINE version of the 1328 page
Scripting Guide: http://www.microsoft.com/technet/scriptcenter


Jay [Work]

unread,
May 9, 2003, 11:53:41 AM5/9/03
to
this is what I needed.. thanks

jay

"Torgeir Bakken (MVP)" <Torgeir.B...@hydro.com> wrote in message
news:3EBAF910...@hydro.com...

Jay [Work]

unread,
May 9, 2003, 11:54:10 AM5/9/03
to
thanks
"Robert Cohen" <rco...@bbhtx.org> wrote in message
news:O$bQIEbFD...@TK2MSFTNGP10.phx.gbl...

Alex K. Angelopoulos (MVP)

unread,
May 9, 2003, 10:30:54 PM5/9/03
to
Torgeir Bakken (MVP) wrote:

> From command lie (Win2k/WinXP):
>
> Control.exe TIMEDATE.CPL,,/Z (GMT-08:00) Pacific Time (US & Canada);
> Tijuana
>
> alternatively:
> RUNDLL32.EXE SHELL32.DLL,Control_RunDLL TIMEDATE.CPL,,/Z (GMT-08:00)
> Pacific Time (US & Canada); Tijuana
>
> where '(GMT-08:00) Pacific Time (US & Canada); Tijuana' is the timezone
> to be set.

This is pretty slick! What's this based on, any "Display" value from
underneath 'HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Time Zones'?
Is there a way to do a static zone based on one of the shorter values in
the time zone table?

What's this based on?

--
Please respond in the newsgroup so everyone may benefit.
http://dev.remotenetworktechnology.com
(email requests for support contract information welcomed)
----------
Microsoft's new UNIFIED Terminal Services Newsgroup:
news:microsoft.public.windows.terminal_services

Torgeir Bakken (MVP)

unread,
May 9, 2003, 11:04:02 PM5/9/03
to
"Alex K. Angelopoulos (MVP)" wrote:

> Torgeir Bakken (MVP) wrote:
>
> > From command lie (Win2k/WinXP):
> >
> > Control.exe TIMEDATE.CPL,,/Z (GMT-08:00) Pacific Time (US & Canada);
> > Tijuana
>

> This is pretty slick! What's this based on, any "Display" value from
> underneath 'HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Time Zones'?
> Is there a way to do a static zone based on one of the shorter values in
> the time zone table?

Hi

Yes, the "Display" value, and it looks like you can use the Std value in those
registry keys as well, this is equivalent with the line above:

Control.exe TIMEDATE.CPL,,/Z Pacific Standard Time

0 new messages