PDA

Click to See Complete Forum and Search --> : Date/Time Locale Information


Nov 25th, 1999, 03:46 PM
Hi,

Does anybody know how to obtain the current date and time settings as defined in the Regional icon in Control panel?

Thanks;


------------------
Richard Moss

ariad@globalnet.co.uk
http://www.users.globalnet.co.uk/~ariad/

john_murphy
Nov 25th, 1999, 07:27 PM
Hope this is what you want.

john_m_murphy@hotmail.com
Galway
Ireland
GetTimeZoneInformation Function

private Declare Function GetTimeZoneInformation Lib "kernel32.dll" (lpTimeZoneInformation As TIME_ZONE_INFORMATION) As Long

Platforms: Win 95/98, Win NT

GetTimeZoneInformation reads the computer's current time zone settings. Since Windows handles all of the system clock settings, there usually isn't a need for other programs to use this information. The information is put into the variable passed as lpTimeZoneInformation. The function returns 0 if an error occured, or a 1 if successful.

lpTimeZoneInformation
Variable which receives the information about the system time zone.
Example:

' Display the name of the time zone the computer is set to.
Dim tzi As TIME_ZONE_INFORMATION ' receives information on the time zone
Dim retval As Long ' return value
Dim c As Long ' counter variable needed to display time zone name

retval = GetTimeZoneInformation(tzi) ' read information on the computer's selected time zone

' Oddly, instead of being stored in a string, the time zone name is stored in a
' 32-element array, each element holding the ASCII code of one of the characters.
' This loop converts the array into a readable string.
Debug.Print "The computer's time zone is: ";
For c = 0 To 31 ' the array's range is from 0 to 31
If tzi.StandardName(c) = 0 Then Exit For ' abort if the terminating null character is reached
Debug.Print Chr(tzi.StandardName(c)) ' convert the ASCII code into a character and display it
Next c
Debug.Print "" ' end the line being displayed