#include <iostream>
#include <time.h>
using namespace std;
int main()
{
time_t t=time(0);//从1970:0:0开始计时到现在经过的秒数
char tmp[64];
strftime(tmp, sizeof(tmp), "%Y/%m/%d/ %X %A", localtime(&t));
cout<<"today is "<<tmp<<endl;
}
输出:
today is 2017/09/17/ 20:37:04 Sunday