#include <time.h>
struct tm *localtime( const time_t *time );
函数返回本地日历时间。
#include <time.h>
#include <stdio.h>
#include <dos.h>
int main(void)
{
time_t timer;
struct tm *tblock;
/* gets time of day */
timer = time(NULL);
/* converts date/time to a structure */
tblock = localtime(&timer);
printf("Local time is: %s", asctime(tblock));
return 0;
}输出结果:
Local time is: Thu Jul 14 23:21:52 2022