Declare Sub GetSystemTime Lib "kernel32.dll" (lpSystemTime As SYSTEMTIME)
GetSystemTime returns the system's time and date -- in Coordinated Universal Time (UTC, also known as Greenwich Mean Time (GMT) or Zulu time) instead of local time. This means that the time and date this function gives you probably won't match what the computer's clock tells you. This is useful in case your program communicates to other computers across time zone lines, and needs a universal time to reference anywhere. The various features of the time and date (month, day, hour, minute, second, etc.), down to the millisecond, are sorted in the variable passed as lpSystemTime!
Example:
Dim loctime As SYSTEMTIME
' Print the date in mm-dd-yyyy format.
' (Since this is UTC time, the date may be different!)
GetSystemTime systime
Debug.Print systime.wMonth; "-"; systime.wDay; "-" systime.wYear
Related Call: GetLocalTime
Category: System Information
Back to the index.