[ create a new paste ] login | about

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

slevy1ster - C, pasted on Jun 27:
#include <stdio.h>
#include <time.h>
 
typedef struct hour{
 
int hour;
int minute;
int second;
int isdst;
 
} Hour;
 
typedef struct date{
 
int day;
int month;
int year;
Hour hr;
 
} Date;
 
int main (void) {
 
 
Date d;
 
time_t now = time(0);
struct tm temp;
char buffer[80];
const char *format = "%m-%d-%Y %H:%M:%S";
 
temp = *localtime( &now );
 
d.day       = temp.tm_mday;
d.month     = temp.tm_mon;
d.year      = temp.tm_year;
d.hr.hour   = temp.tm_hour;
d.hr.minute = temp.tm_min;
d.hr.second = temp.tm_sec;
d.hr.isdst  = temp.tm_isdst;
 
 
strftime (buffer, 80, format, &temp);
printf("Current local date and time: %s",buffer);
 
return(0);
 
}


Output:
1
Current local date and time: 06-27-2017 08:40:36


Create a new paste based on this one


Comments: