/* 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);
time_h && struct tm
时间: 2024-10-08 01:15:28