码迷,mamicode.com
首页 > 其他好文 > 详细

爱上C之:time

时间:2016-10-15 14:16:45      阅读:87      评论:0      收藏:0      [点我收藏+]

标签:

Show_Current_Time:

 1 #include <time.h>
 2 #include <stdio.h>
 3 
 4 int main(void)
 5 {
 6     char* weekday[] = {"Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"};
 7     time_t Now = time(NULL);
 8     struct tm* Tvar = localtime(&Now);
 9     printf("Current time is : %4i-%02i-%02i[%s] %02i:%02i:%02i\n", Tvar->tm_year + 1900, Tvar->tm_mon + 1, Tvar->tm_mday, weekday[Tvar->tm_wday], Tvar->tm_hour, Tvar->tm_min, Tvar->tm_sec);
10     return 0;
11 }
tiger@animal ~/cc $ ./time_Now 
Current time is : 2016-10-15[Saturday] 13:08:55
技术分享localtime(time_t *)

 

爱上C之:time

标签:

原文地址:http://www.cnblogs.com/hadex/p/5964229.html

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