获取系统时间的两种方法

SYSTEMTIME time;        //使用结构体
GetLocalTime(&time);    //获取当前时间
CString strCurTime;
strCurTime.Format("%4.4d-%2.2d-%2.2d %2.2d:%2.2d:%2.2d",time.wYear,time.wMonth,time.wDay,time.wHour,time.wMinute,time.wSecond);
CTime time=CTime::GetCurrentTime(); //使用GetCurrentTime()构造函数初始化time对象
CString strCurTime;
strCurTime.Format("%4.4d-%2.2d-%2.2d %2.2d:%2.2d:%2.2d",time.GetYear(),time.GetMonth(),time.GetDay(),time.GetHour(),time.GetMinute(),time.GetSecond());

你可能感兴趣的:(获取系统时间的两种方法)