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;
}
wstring 转 utc时间
最新推荐文章于 2024-11-08 23:39:16 发布