[ create a new paste ] login | about

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

slevy1ster - C, pasted on Jun 27:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#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);
}


Output:
1
Current local date and time: 06-27-2017 09:52:03


Create a new paste based on this one


Comments: