This is an example C program illustrating the use of
time, localtime_r, and strftime
to print today's date.
#include <stdio.h> #include <time.h> #define SIZE 0x100 int main () { time_t t; char buffer[SIZE]; struct tm ltime; t = time (0); localtime_r (& t, & ltime); strftime (buffer, SIZE, "%A, %e of %B %Y", & ltime); printf ("Today is %s.\n", buffer); return 0; }
The output of the example looks like this:
Today is Monday, 12 of September 2011.