Calculating the time difference

I want to find out the time difference,say i start walking from my home at 23 hr 10 min 25 seconds and I reach destination at 1 hr 10 min 25 seconds.. I know here the time difference is 1 hr 55 min 55 seconds. But how am I gonna calculate this??
It's easier to do the calculations if you convert everything into seconds. When you want to display the result you just convert it back into hours, minutes and seconds.
Can u explain pls peter? Can u show the calculation here?? :(
suppose you have for example 3559 secs.
cout<<time/3600<<" hours\n";
cout<<(time%3600)/60<<" minutes\n";
cout<<(time%60)%60<< " secs\n";

would give and output of 1 hour, 1 min, and 1 sec. Peter87 is just saying it is easier to calculate the time difference by changing the times to secs, add or subject to corresponding time differences then use that solution up there to calaculate it back to 24 hr clock.

23 hr 10 min 25 seconds would be (23*3600)+(10*60)+25=83425 secs

Topic archived. No new replies allowed.