asctime, asctime_r
Converts the time information into a string
#include <time.h> char *asctime ( const struct tm *timeptr);
#include <time.h> char *asctime_r ( const struct tm *timeptr, char *string);
Returns a pointer to the character string result.
asctime and asctime_r convert the time information in the structure pointed to by timeptr into a string containing exactly 26 characters.
This string has the form shown in the following example:
Wed Mar 21 15:58:27 1990\n\0
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 asctime is called.
asctime_r provides the same functionality as asctime, but asctime_r is designed for use with reentrant NLMs. asctime_r provides that the caller pass storage for the results rather than relying on per-thread data. asctime_r is supported only in CLIB V 4.11 or above.
clock, ctime, ctime_r, difftime, gmtime, gmtime_r, localtime, localtime_r, mktime, strftime, time
#include <stdio.h> #include <time.h> main () { struct tm *time_of_day; time_t ltime; time (<ime); time_of_day = localtime (<ime); printf ("Date and time is: %s.Get to work.", asctime (time_of day)); }
produces the following:
Date and time is: Wed Mar 21 15:58:27 1990 .Get to work.