28 lines
886 B
C++
28 lines
886 B
C++
|
|
#include "VrDateUtils.h"
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* <EFBFBD><EFBFBD>ȡʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
*/
|
|||
|
|
std::string CVrDateUtils::GetNowTime()
|
|||
|
|
{
|
|||
|
|
time_t tt = std::chrono::system_clock::to_time_t(std::chrono::system_clock::now());
|
|||
|
|
#ifdef _WIN32
|
|||
|
|
struct tm ptminfo;
|
|||
|
|
localtime_s(&ptminfo, &tt);
|
|||
|
|
#else
|
|||
|
|
struct tm ptminfo = *(localtime(&tt));
|
|||
|
|
#endif
|
|||
|
|
//printf("current: %02d-%02d-%02d %02d:%02d:%02d\n",
|
|||
|
|
// ptminfo.tm_year + 1900, ptminfo.tm_mon + 1, ptminfo.tm_mday,
|
|||
|
|
// ptminfo.tm_hour, ptminfo.tm_min, ptminfo.tm_sec);
|
|||
|
|
char date[60] = { 0 };
|
|||
|
|
#ifdef _WIN32
|
|||
|
|
sprintf_s(date, "%02d%02d%02d%02d%02d%02d", ptminfo.tm_year + 1900, \
|
|||
|
|
ptminfo.tm_mon + 1, ptminfo.tm_mday, ptminfo.tm_hour, ptminfo.tm_min, ptminfo.tm_sec);
|
|||
|
|
#else
|
|||
|
|
sprintf(date, "%02d%02d%02d%02d%02d%02d", ptminfo.tm_year + 1900, \
|
|||
|
|
ptminfo.tm_mon + 1, ptminfo.tm_mday, ptminfo.tm_hour, ptminfo.tm_min, ptminfo.tm_sec);
|
|||
|
|
#endif
|
|||
|
|
return std::string(date);
|
|||
|
|
}
|