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