直接上代码
#include <stdio.h>
#include <time.h>
int main(){
time_t tmpcal_t;
struct tm *tmp_ptr = NULL;
time(&tmpcal_t);
tmp_ptr = localtime(&tmpcal_t);
printf ("the time is:%d.%d.%d ",
(1900+tmp_ptr->tm_year),
(1+tmp_ptr->tm_mon),
tmp_ptr->tm_mday);
printf("%d:%d:%d\n",
tmp_ptr->tm_hour,
tmp_ptr->tm_min,
tmp_ptr->tm_sec);
}