时间格式转换问题,请回答谢谢 有这样一种64位的日期/时间格式,比如值为0x01C46325D5B85130,应该如何转换为XXXX年XX月XX日XX点XX分XX秒啊。谢谢了 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 用64位的日期值作为参数创建一个COleDateTime对象,然后用COleDateTime::Format. FILETIME ftime; __int64 nTime64; nTime64 = 0x01C46325D5B85130; CopyMemory(&ftime, &nTime64, sizeof(nTime64)); COleDateTime datetime(ftime); CString strTime; int nYear = datetime.GetYear(); int nMonth = datetime.GetMonth(); int nDay = datetime.GetDay(); int nHour = datetime.GetHour(); int nMin = datetime.GetMinute(); int nSec = datetime.GetSecond(); strTime.Format("%d年%d月%d日%d点%d分%d秒", nYear, nMonth, nDay, nHour, nMin, nSec); CString GetTimeString(__int64 nTime){ FILETIME ft; FILETIME localFt; SYSTEMTIME st; CopyMemory(&ft,&nTime,sizeof(nTime)); FileTimeToLocalFileTime(&ft,&localFt); FileTimeToSystemTime(&localFt,&st); CString sTime; sTime.Format("%04d年%02d月%02d日%02d点%02d分%02d秒",st.wYear,st.wMonth,st.wDay,st.wHour,st.wMinute,st.wSecond); retur sTime;} 我再贴:SYSTEMTIME *curDateTime=new SYSTEMTIME; ::GetLocalTime(curDateTime); DWORD year=curDateTime->wYear; DWORD month=curDateTime->wMonth; DWORD day=curDateTime->wDay; DWORD hour=curDateTime->wHour; DWORD minute=curDateTime->wMinute; DWORD second=curDateTime->wSecond; DWORD millisecond=curDateTime->wMilliseconds; CString sCurTime ; sCurTime.Format("\\T%d%d%d%d%d%d%d.trs", year, month, day, hour, minute, second, millisecond); //TRACE0(sCurTime); strCString="2003-10-27 6:24:37"; //CString--->COleDateTimeCOleVariant vtime(strCString);vtime.ChangeType(VT_DATE);COleDateTime time4=vtime;COleDateTime time1(1977,4,16,2,2,2); //COleDataTime--->CTimeSYSTEMTIME systime;VariantTimeToSystemTime(time1, &systime);CTime tm(systime);time_t time2=tm.GetTime(); //CTime--->time_tCOleDateTime time3(time2); //time_t--->COleDateTime 求VC6下JPG解码源程序。 如何实现CInternetSession下载加速? MFC崩溃后自动重启软件 实现原理 Static控件里如何实现字符串的滚动(就像游戏中的系统公告) 当同一个线程函数被周期性的调用时,在线程函数内部使用临界区对象保护,这样能保证线程同步吗? 属性分割条 如何在MDI里添加一个控制台 VC6.0转VS2008时编译VTK出错,请大侠指教!! [转]网游辅助(外挂)程序开发教程及实例分析 求救:一个VC中多线程的问题 那位弟兄有在string中模式匹配查找的函数阿? 有关VC的几个简单问题,在线等!!谢谢了!
__int64 nTime64;
nTime64 = 0x01C46325D5B85130;
CopyMemory(&ftime, &nTime64, sizeof(nTime64));
COleDateTime datetime(ftime);
CString strTime;
int nYear = datetime.GetYear();
int nMonth = datetime.GetMonth();
int nDay = datetime.GetDay();
int nHour = datetime.GetHour();
int nMin = datetime.GetMinute();
int nSec = datetime.GetSecond();
strTime.Format("%d年%d月%d日%d点%d分%d秒",
nYear, nMonth, nDay, nHour, nMin, nSec);
{
FILETIME ft;
FILETIME localFt;
SYSTEMTIME st;
CopyMemory(&ft,&nTime,sizeof(nTime));
FileTimeToLocalFileTime(&ft,&localFt);
FileTimeToSystemTime(&localFt,&st);
CString sTime;
sTime.Format("%04d年%02d月%02d日%02d点%02d分%02d秒",st.wYear,st.wMonth,st.wDay,st.wHour,st.wMinute,st.wSecond);
retur sTime;
}
我再贴:
SYSTEMTIME *curDateTime=new SYSTEMTIME;
::GetLocalTime(curDateTime);
DWORD year=curDateTime->wYear;
DWORD month=curDateTime->wMonth;
DWORD day=curDateTime->wDay;
DWORD hour=curDateTime->wHour;
DWORD minute=curDateTime->wMinute;
DWORD second=curDateTime->wSecond;
DWORD millisecond=curDateTime->wMilliseconds;
CString sCurTime ;
sCurTime.Format("\\T%d%d%d%d%d%d%d.trs", year, month, day, hour, minute, second, millisecond);
//TRACE0(sCurTime);
COleVariant vtime(strCString);
vtime.ChangeType(VT_DATE);
COleDateTime time4=vtime;COleDateTime time1(1977,4,16,2,2,2); //COleDataTime--->CTime
SYSTEMTIME systime;
VariantTimeToSystemTime(time1, &systime);
CTime tm(systime);time_t time2=tm.GetTime(); //CTime--->time_t
COleDateTime time3(time2); //time_t--->COleDateTime