MFC 獲取系統時間

 CTime t=CTime::GetCurrentTime(); //得到當前系統時間

int year = time.GetYear(); //返回年
int mouth = time.GetMouth(); //返回月份
int date = time.GetDay(); // 返回日數
int hour = time.GetHour(); // 返回小時數(-23至23之間)
int min = time.GetMinute(); // 返回分鐘數(-59至59之間)
int sec = time.GetSecond(); // 返回秒數(-59至59之間)

//轉化爲字符串

 CString strTime;
 strTime.Format("%d%d%d%d%d%d",t.GetYear(),t.GetMonth(),t.GetDay(),t.GetHour(),t.GetMinute(),t.GetSecond());

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