Struct tm
struct tm Tm1 = {0}; //<<The = {0} is really important to ensure the struct if properly initialised, you can sometimes get weird runtime issues if you don't do this
Tm1.tm_year = (2015 - 1900); //years since 1900 (we must be >= 1970 for time_t based calcs)
Tm1.tm_mon = 1; //months since January (0-11)
Tm1.tm_mday = 18;
Tm1.tm_hour = 12;
Tm1.tm_min = 03;
Tm1.tm_sec = 48;
Note:
tm_year is years since 1900!!
tm_month is months since January (0-11)!!
Note when converting to time_t your year must be >= 1970 as time_t is usually based from 00:00, Jan 1 1970 UTC!
Copy struct tm
You can just use a normal equals:
struct tm Tm1 = {0};
struct tm Tm2 = {0};
//...
Tm2 = Tm1;
