Private Sub Command1_Click()
Dim the_date As Date Dim system_time As SYSTEMTIME Dim local_file_time As FILETIME Dim utc_file_time As FILETIME ' Get the local time. the_date = CDate(txtLocalTime.Text) ' Convert it into a SYSTEMTIME. DateToSystemTime the_date, system_time ' Convert it to a FILETIME. SystemTimeToFileTime system_time, local_file_time ' Convert it to a UTC time. LocalFileTimeToFileTime local_file_time, utc_file_time ' Convert it to a SYSTEMTIME. FileTimeToSystemTime utc_file_time, system_time ' Convert it to a Date. SystemTimeToDate system_time, the_date ' Display the result. txtUTCTime.Text = Format$(the_date) End Sub 'Reverse the steps to go from a UTC time to the 'local file system time. Use the SystemTimeToFileTime API function to convert the SYSTEMTIME into a FILETIME structure. Use the LocalFileTimeToFileTime API function to convert from the localtime to UTC time. Use the FileTimeToSystemTime API function to convert the UTC time into a SYSTEMTIME structure. Pull the fields out of the SYSTEMTIME to get the Visual Basic date format. |