码迷,mamicode.com
首页 > 编程语言 > 详细

c/c++本地时间获取

时间:2018-06-04 20:10:18      阅读:162      评论:0      收藏:0      [点我收藏+]

标签:color   localtime   AC   ftime   win   结果   stream   space   code   

在记录程序日志时,需要记录时间。如下:

#include <iostream>
#include <time.h>
#include <windows.h>
using namespace std;
int main() {
    time_t t = time(0);
    char tmp[64];
    strftime(tmp, sizeof(tmp), "%Y/%m/%d %X %A %j %z", localtime(&t));
    cout << tmp << endl;
    system("pause");
    return 0;
}

即Y为年、m为月、d为日、X为具体时分秒、A为星期、j为天数、z为其他,结果如下:

2018/06/04 19:52:54 Monday 155 China Standard Time

 

c/c++本地时间获取

标签:color   localtime   AC   ftime   win   结果   stream   space   code   

原文地址:https://www.cnblogs.com/zhuzhenwei918/p/9135142.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!