Function name : localtime
Header file : <time.h>
Usage : struct tm *localtime(long *clock);
Function : Convert date and time into structure tm
Parameters : Time to convert, in seconds
Return value : Returns the local standard time in the form of tm structure
Program example : Get the system time function of the tm structure and output the result
#include<stdio.h>#include<time.h>intmain(void){time_ttimer;structtm*tblock;timer=time(NULL);//Get the current time tblock=localtime(&timer);char*str=asctime( tblock);//Convert the tm structure into a string printf(Localtimeis:%s,str);return0;}
Running results:
Localtimeis:TueJun1621:01:542020