#include <time.h>
char *ctime( const time_t *time );
函数转换参数time为本地时间格式:
day month date hours:minutes:seconds year\n\0
ctime() 等同
asctime( localtime( tp ) );
#include <stdio.h> #include <time.h> int main(void) { time_t t; time(&t); printf("Today's date and time: %s\n", ctime(&t)); return 0; }
输出结果:
Today's date and time: Thu Jul 14 23:15:05 2022