- TzSpecificLocalTimeToSystemTime:Local time -> UTC
- SystemTimeToTzSpecificLocalTime :UTC -> Local time
SYSTEMTIME ConvertLocalTime2UTC(UINT year, UINT month, UINT day, UINT hour, UINT minute, UINT second) { SYSTEMTIME local, utc; ZeroMemory(&local, sizeof(local)); local.wYear = year; local.wMonth = month; local.wDay = day; local.wHour = hour; local.wMinute = minute; local.wSecond = second; TzSpecificLocalTimeToSystemTime( NULL, &local, &utc ); printf("UTC Time =%d/%d/%d %d:%d:%d\n", utc.wYear, utc.wMonth, utc.wDay, utc.wHour, utc.wMinute, utc.wSecond); printf("Local Time=%d/%d/%d %d:%d:%d\n", local.wYear, local.wMonth, local.wDay, local.wHour, local.wMinute, local.wSecond); return utc; } SYSTEMTIME ConvertUTC2LocalTime(UINT year, UINT month, UINT day, UINT hour, UINT minute, UINT second) { SYSTEMTIME local, utc; ZeroMemory(&utc, sizeof(utc)); utc.wYear = year; utc.wMonth = month; utc.wDay = day; utc.wHour = hour; utc.wMinute = minute; utc.wSecond = second; SystemTimeToTzSpecificLocalTime( NULL, &utc, &local ); printf("UTC Time =%d/%d/%d %d:%d:%d\n", utc.wYear, utc.wMonth, utc.wDay, utc.wHour, utc.wMinute, utc.wSecond); printf("Local Time=%d/%d/%d %d:%d:%d\n", local.wYear, local.wMonth, local.wDay, local.wHour, local.wMinute, local.wSecond); return local; }
Reference: