The C library function char *ctime(const time_t *timer) returns a string representing the localtime based on the argument timer.
The returned string has the following format − Www Mmm dd hh:mm:ss yyyy, where Www is the weekday, Mmm the month in letters, dd the day of the month, hh:mm:ss the time, and yyyy the year.
The syntax is like below −
char *ctime(const time_t *timer)
This function takes the pointer to a time_t, which is containing the calendar time. It returns a string containing date, time info in human readable format.
Example
#include <stdio.h> #include <time.h> int main () { time_t curtime; time(&curtime); printf("Current time = %s", ctime(&curtime)); return(0); }
Output
Current time = Thu May 23 17:18:43 2019