NAME
ctime ctime_r
— convert a time value to date and time
string
SYNOPSIS
#include <time.h> char *ctime(const time_t *clock); char *ctime_r(const time_t *clock, char *buf);
DESCRIPTION
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 asctime(), ctime(), gmtime() and localtime() functions return values in one of two static objects: a broken-down time structure and an array of char. 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 clock 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 tzname.
RETURN VALUE
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.
ERRORS
No errors are defined.
EXAMPLES
None.
APPLICATION USAGE
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.
FUTURE DIRECTIONS
None.
SEE ALSO
asctime(3) , clock(3) , difftime(3) , gmtime(3) , localtime(3) , mktime(3) , strftime(3) , strptime(3) , time(3) , utime(3) , <time.h> .
DERIVATION
ctime() derived from Issue 1 of the SVID.
ctime_r() derived from the POSIX Threads Extension (1003.1c-1995).