Results 1 to 2 of 2

Thread: Date/Time Locale Information

  1. #1
    Guest

    Post

    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

    [email protected]
    http://www.users.globalnet.co.uk/~ariad/


  2. #2
    Hyperactive Member
    Join Date
    Nov 1999
    Location
    Galway, Ireland
    Posts
    316

    Post

    Hope this is what you want.

    [email protected]
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width