C++获取系统当前时间并以字符串格式返回

string GetSystemTime()
{
SYSTEMTIME m_time;
GetLocalTime(&m_time);
char szDateTime[100] = { 0 };
sprintf(szDateTime, “%02d-%02d-%02d %02d:%02d:%02d”, m_time.wYear, m_time.wMonth,
m_time.wDay, m_time.wHour, m_time.wMinute, m_time.wSecond);
string time(szDateTime);
return time;
}

你可能感兴趣的:(C++获取系统当前时间并以字符串格式返回)