CTIME(3) Library Functions Manual CTIME(3)

ctime ctime_rconvert a time value to date and time string

#include <time.h>

char *ctime(const time_t *clock);
char *ctime_r(const time_t *clock, char *buf);

The ctime() function converts the time pointed to by clock , representing time in seconds since the Epoch, to local time in the form of a string. It is equivalent to:

asctime(localtime(clock))

The , ctime(), and functions return values in one of two static objects: a broken-down time structure and an array of . Execution of any of the functions may overwrite the information returned in either of these objects by any of the other functions.

The ctime() interface need not be reentrant.

The ctime_r() function converts the calendar time pointed to by to local time in exactly the same form as ctime() and puts the string into the array pointed to by buf (which contains at least 26 bytes) and returns buf.

Unlike ctime(), the thread-safe version ctime_r() is not required to set .

The ctime() function returns the pointer returned by asctime(3) with that broken-down time as an argument.

On successful completion, ctime_r() returns a pointer to the string pointed to by buf. When an error is encountered, a NULL pointer is returned.

No errors are defined.

None.

Values for the broken-down time structure can be obtained by calling gmtime(3) or localtime(3) . This interface is included for compatibility with older implementations, and does not support localised date and time formats. Applications should use the strftime(3) interface to achieve maximum portability.

None.

asctime(3) , clock(3) , difftime(3) , gmtime(3) , localtime(3) , mktime(3) , strftime(3) , strptime(3) , time(3) , utime(3) , <time.h> .

ctime() derived from Issue 1 of the SVID.

ctime_r() derived from the POSIX Threads Extension (1003.1c-1995).

February 1997 posix.fail