wstring 转 utc时间

来源:互联网 发布:mac understand破解版 编辑:程序博客网 时间:2024/05/06 18:16
tstring CMainFunction::StringToUTC( tstring cStr)  {  TCHAR rcStr[MAX_PATH] = {0} ;  int nYear, nMonth, nDate, nHour, nMin, nSec;  swscanf_s( cStr.c_str(),_T("%d-%d-%d %d:%d:%d"), &nYear, &nMonth, &nDate, &nHour, &nMin, &nSec );  CTime cTime(nYear, nMonth, nDate, nHour, nMin, nSec);  SYSTEMTIME timeFrom;  cTime.GetAsSystemTime(timeFrom);  SYSTEMTIME tm_ptr = {0};  TIME_ZONE_INFORMATION tz = {0};  tz.Bias = -480;  TzSpecificLocalTimeToSystemTime( &tz, &timeFrom, &tm_ptr);  _sntprintf_s( rcStr, _countof(rcStr), _T("%04d-%02d-%02d %02d:%02d:%02d") ,tm_ptr.wYear, tm_ptr.wMonth, tm_ptr.wDay, tm_ptr.wHour, tm_ptr.wMinute, tm_ptr.wSecond);  return rcStr;  } 

0 0
原创粉丝点击