/* time_h的使用 */
//第一种方式
time_t timer1;
time(&timer1);
//第二种方式
time_t timer2;
timer2 = time(NULL);
//第三种方式
time_t timer3 = time(NULL);
/*struct tm 的使用*/
struct tm *now;
timer_t timer = time(NULL);
now = localtime(&timer);
printf("%s\n",asctime(now));
printf("%04d",now->tm_year);
printf("%02d",now->tm_mon);
printf("%02d",now->tm_mday);
原文地址:http://kinghero.blog.51cto.com/10493576/1672807