How to convert and print full system TIME string in GMT or UTC

SYSTEMTIME tempSYSTIME;
SYSTEMTIME stLocal;
FILETIME LocalTime;
int TmpMeetingInfoLength = 0;
TCHAR tempStartTimeStr[MAX_PATH] ;

TCHAR strDateandTime[MAX_PATH];
TIME_ZONE_INFORMATION info;
GetLocalTime(&stLocal);
GetTimeZoneInformation(&info);
LONG tmpval = info.Bias ;


if(info.Bias<0)
tmpval = info.Bias * -1;
LONG hr , min ;
hr = tmpval /60;
min = tmpval % 60;
_TCHAR str[100];
_stprintf(str, _T(": %02d-%02d-%02d %02d:%02d:%02d GMT%s%02ld:%02ld"),stLocal.wYear ,stLocal.wMonth, stLocal.wDay,
stLocal.wHour, stLocal.wMinute ,stLocal.wSecond , (info.Bias > 0 && info.Bias != 0 ) ?_T("-"): _T("+"),hr , min);

OUTPUT : "YYYY-MM-DD HH:MM:SS GMT+/- HH:MM"
eg: "2009-10-10 23:15:01 GMT +05:30"

Comments

Popular posts from this blog

XML Programming using IXMLDOMDOCUMENT in vc++

Get correct OS version on win 8.1 without using GetVesionEx API (deprecated )