您的位置:首页 > 其它

时间函数---转换成指定格式的时间函数

2015-04-19 23:50 134 查看
time_t t;  //秒时间  

tm* local; //本地时间   

tm* gmt;   //格林威治时间  

char buf[128]= {0};  

  

t = time(NULL); //获取目前秒时间  

local = localtime(&t); //转为本地时间  

strftime(buf, 64, "%Y-%m-%d %H:%M:%S", local);  

std::cout << buf << std::endl;  

  

gmt = gmtime(&t);//转为格林威治时间  

strftime(buf, 64, "%Y-%m-%d %H:%M:%S", gmt);  

std::cout << buf << std::endl; 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: