最近要使用CString转UCT的实现网上找了很多都没找到,所以就自己写了一个
希望对同样也有需要的朋友有帮助
</pre><pre name="code" class="cpp">#include# WinBase.h //头文件
CString CStringToUTC( CString cStr)
{
CString rcStr;
int nYear, nMonth, nDate, nHour, nMin, nSec;
swscanf_s(cStr.GetBuffer(cStr.GetLength()),_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);
rcStr.Format(_T("%d-%d-%d %d:%d:%d") ,tm_ptr.wYear, tm_ptr.wMonth, tm_ptr.wDay, tm_ptr.wHour, tm_ptr.wMinute, tm_ptr.wSecond);
return rcStr;
}
TzSpecificLocalTimeToSystemTime函数的具体含义可以查询MSDN