[ create a new paste ] login | about

Link: http://codepad.org/lGpWpf4h    [ raw code | output | fork ]

slevy1ster - C, pasted on Jun 27:
#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);
}


Output:
1
2

Current local date and time: 06-27-2017 13:11:24


Create a new paste based on this one


Comments: