C++ method to get the current time
- 2020-04-02 02:49:33
- OfStack
This article is an example of C++ to get the current time method, to share with you for your reference.
The specific implementation method is as follows:
//Local time & NBSP; < br / >
BOOL GetTime(string &mytime)
{
BOOL b_ret = TRUE;
CHAR szBuf1[256]={0};
CTime tNow = CTime::GetCurrentTime();
sprintf(szBuf1,"%04u%02u%02u%02u%02u%02u",tNow.GetYear(),tNow.GetMonth(),tNow.GetDay(),tNow.GetHour(),tNow.GetMinute(),tNow.GetSecond());
mytime = szBuf1;
return b_ret;
}
Hope that the article described in the C++ programming to help you.