Function name : ctime
Header file : <time.h>
Function prototype : char *ctime(const time_t *time);
Function : Convert date and time to string
Parameters : Date and time to be converted
Return value : Returns the converted string pointer
Replenish :
Www Mmm dd hh:mm:ss yyyy
Www means day of the week
Mmm is the month in letters
dd represents the day of the month
When hh:mm:ss indicates
yyyy represents the year
Program example: Get the system time, convert it into a string, and output the result
#include<stdio.h>#include<time.h>intmain(void){time_tt;//typedeflongtime_t;time(&t);//Get the system time char*str=ctime(&t);//Convert time t For string printf(Today'sdateandtime:%sn,str);return0;}
Running results:
Today'sdateandtime:TueJun1618:02:262020