I am receiving a date structure in "24-9-2016 13:30" format. Now I want to convert time value to specific date value, I am doing calculations and have number of hours to add or subtract.
So I don't know:
- how can I initialize tm struct with the date value I have?
- how to add or subtract hours in tc struct variable to get required date?
my intention is
Date received "24-9-2016 13:30" and 5 Hours to add
so final Date: "24-9-2016 18:30"
//Temporarily init time to local
time_t tempTime
time(&tempTime);
struct tm *initStruct = localtime(&tempTime);//initialize it with local time
//now modify it to user defined date
initStruct ->tm_year = 2016;
initStruct->tm_mon = 9;
initStruct->tm_hour = 13;
.
.
.
//Not sure how can I subtract or add hours in this struct to get desired date value
This is about formatting user defined not a duplicate.