C programming time.h function - char *ctime(const time_t *timer)

www.igift‮edi‬a.com

The ctime function is used to convert a time_t value representing a calendar time to a string representation of the corresponding local time.

Here's the syntax of the ctime function:

char *ctime(const time_t *timer);

The timer argument is a pointer to a time_t object representing the calendar time to be converted. The return value is a pointer to a string representing the corresponding local time, in the form:

Day Month Date hours:minutes:seconds Year\n\0

where:

  • Day is the abbreviated name of the day of the week ("Sun", "Mon", etc.).
  • Month is the abbreviated name of the month ("Jan", "Feb", etc.).
  • Date is the day of the month (1-31).
  • Year is the year (minus 1900).
  • hours, minutes, and seconds are the time in hours (0-23), minutes (0-59), and seconds (0-60, allowing for leap seconds), respectively.

Note that the string returned by ctime includes a newline (\n) character and a terminating null character (\0).