#include <stdio.h>
#include <time.h>
int main (void) {
time_t now = time(0);
struct tm date;
struct tm * result;
char buffer[80];
const char *format = "%m-%d-%Y %H:%M:%S";
// store current local date and time in date tm structure...
result = localtime_r( &now, &date );
// ... and safely display it
strftime (buffer, 80, format, result);
printf("Current local date and time: %s",buffer);
return(0);
}