0
点赞
收藏
分享

微信扫一扫

C++ 获取当前时间

字符串时间:

= time(0);
char now[64];
strftime(
now, // 接收时间的字符串
sizeof(now)-1, // 被复制到字符串的最大字节数
"%Y-%m-%d %H:%M:%S", // 输出时间的格式(年月日时分秒)
localtime(&t) // 指向 tm 结构的指针
);

时间戳:

;
time(&t);
cout << "时间戳 = " << t << endl;



举报

相关推荐

0 条评论