Hey everyone. I\'ve continuing to learn C++ and I\'ve been set the \'challenge\' of converting seconds to format as the Days,Minutes and Seconds.
For example: 316000
this seems to me to be the easiest way to convert seconds into DD/hh/mm/ss:
#include
#include
using namespace std;
time_t seconds(1641); // you have to convert your input_seconds into time_t
tm *p = gmtime(&seconds); // convert to broken down time
cout << "days = " << p->tm_yday << endl;
cout << "hours = " << p->tm_hour << endl;
cout << "minutes = " << p->tm_min << endl;
cout << "seconds = " << p->tm_sec << endl;
I hope it helps!
Regards,
Stoycho