strftime
Formats the time into an array under format control
#include <time.h> size_t strftime ( char *s, size_t maxsize, const char *format, const struct tm *timeptr);
If the number of characters to be placed into the array is less than the value specified by the maxsize parameter, the number of characters placed into the array pointed to by the s parameter (not including the terminating NULL character) will be returned. Otherwise, a value of 0 is returned. If an error occurs, errno is set.
strftime formats the time in the timeptr parameter into the array pointed to by the s parameter according to the format parameter and is not enabled for international use.
The format parameter string consists of zero or more directives and ordinary characters. A directive consists of a % character followed by a character that determines the substitution that is to take place. All ordinary characters are copied unchanged into the array. No more than the number of characters specified by the maxsize parameter are placed in the array.
asctime, asctime_r, clock, ctime, ctime_r, difftime, gmtime, gmtime_r, localtime, localtime_r, mktime, setlocale (Internationalization), time
#include <stdio.h> #include <time.h> main() { time_t time_of_day; char buffer[80]; time_of_day = time (NULL); strftime (buffer, 80, "Today is %A %B %d, %Y", localtime (&time_of_day) ); printf ("%s\n", buffer); }
produces the following:
Today is Friday December 25, 1990