ctime, ctime_r
Converts the calendar time to local time in the form of a string
#include <time.h>
char *ctime (
const time_t *timer);
#include <time.h> char *ctime_r ( const time_t *timer, char *string);
Returns the pointer to the string containing the local time.
ctime, ctime_r converts the calendar time information in the timer structure into a local-time string containing 26 characters.
The string has the form shown in the following example:
Wed Mar 21 15:58:27 1990\n\0
The string is equivalent to:
asctime (localtime (timer) )
All fields have a constant width. The newline character (\n) and the NULL character (\0) occupy the last two positions of the string. The area containing the returned string is reused each time ctime, ctime_r is called.
ctime_r provides the same functionality as ctime, but ctime_r is designed for use with reentrant NLMs. ctime_r provides that the caller pass storage for the results rather than relying on per-thread data. ctime_r is supported only in CLIB V 4.11 or above.
asctime, asctime_r, clock, difftime, gmtime, gmtime_r, localtime, localtime_r, mktime, strftime, time
#include <stdio.h> #include <time.h> void print_time () { time_t time_of_day; time_of_day = time (NULL); printf ("It is now: %s.Get to work.\n", ctime (&time_of_day) ); }
produces the following:
It is now: Tue Dec 25 15:58:42 1990 .Get to work.