ctime function(Convert Date and Time to String) in C Language – example and detail

In the C Programming Language, the ctime function converts a calendar time (pointed to via timer) and returns a pointer to a string describing the nearby time equivalent.


The syntax for the ctime function in the C Language is:

char *ctime(const time_t *timer);

Parameters or Arguments

timer A pointer to an object of kind time_t that carries a time cost to convert.


The ctime feature returns a pointer to a string describing a local time pointed to by timer. It is equivalent to the following asctime characteristic call:


Required Header

In the C Language, the required header for the ctime feature is:

#include <time.h>

Applies To

In the C Language, the ctime feature can be used in the following versions:

ANSI/ISO 9899-1990

Similar Functions

Other C features that are comparable to the ctime function:

asctime feature difftime function gmtime function localtime characteristic mktime feature strftime feature time function