首页 > 代码库 > 将字符串CString类型转换成时间类型

将字符串CString类型转换成时间类型

将字符串CString类型转换成时间类型:

                        //转换时间,替代CStringToDateTime(temp);
			int nYear, nMonth, nDate, nHour, nMin;
			float nSec;
			sscanf(temp, "%d-%d-%d %d:%d:%f", &nYear, &nMonth, &nDate, &nHour, &nMin, &nSec);
			CBHDateTime sTime(nYear, nMonth, nDate, nHour, nMin, nSec); 
                        nSec = nSec - (int)nSec;
			//四舍五入
			int intnSec = (int)((nSec+0.0005)*1000);
			sTime.SetMillisecond(intnSec);


将字符串CString类型转换成时间类型