mfc將sql DateTime轉換成字符串,及格式化當前時間

SYSTEMTIME st;
VariantTimeToSystemTime(date,&st);
CString time;
time.Format(_T("%04d/%02d/%02d %02d:%02d:%02d"),
st.wYear,st.wMonth,st.wDay,st.wHour,st.wMinute,st.wSecond);


獲取當前時間:

SYSTEMTIME curTime;
GetLocalTime(&curTime);
CString strTime;
strTime.Format(_T("%04d-%02d-%02d %02d:%02d:%02d"),curTime.wYear,curTime.wMonth,curTime.wDay,
curTime.wHour,curTime.wMinute,curTime.wSecond);


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章