c++ 时间

time_t timer;
time(&timer);
struct tm tm;
localtime_s(&tm, &timer);
int year = tm.tm_year + 1900;
int month = tm.tm_mon + 1;
int day = tm.tm_mday;
string nDate;
if (month < 10)
{
nDate = to_string(year) + to_string(0) + to_string(month) + to_string(day);
}
else
{
nDate = to_string(year) + to_string(month) + to_string(day);

posted @ 2015-04-22 08:53  现役程序猿  阅读(108)  评论(0编辑  收藏  举报