首页 > 编程语言 > 详细

C++输出当前时间

时间:2021-03-02 10:59:19      阅读:26      评论:0      收藏:0      [点我收藏+]
 1 #include<ctime>
 2 #include<iostream>
 3 using namespace std;
 4 
 5 int main(){
 6     time_t timer;
 7     
 8     timer=time(NULL);//或者 time(&timer);
 9     
10     cout<<timer<<endl;//the number of seconds since 00:00 hours, Jan 1, 1970
11     struct tm *ptr;
12     ptr=localtime(&timer);
13     cout<<asctime(ptr)<<endl;//asctime can Convert tm structure to string
14 }

 

C++输出当前时间

原文:https://www.cnblogs.com/NoerForest/p/14467785.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!