Jul 1, 2011 at 11:35am UTC
Hello
could anyone please tell me how to find out that the difference between the two times is less than equal to one hour e-g
13:32:45.96 - 13:30:10.83 = 0 hours, 2 minits, 35 seconds and 13 mseconds
Thanks
Jul 1, 2011 at 12:17pm UTC
You can try converting a time into the smallest unit of measurement, i.d. convert it to milliseconds. Then you can subtract the two times and convert the result back into the standard format.
02:02:05.10 would be 100 milliseconds plus 5*1000 plus 02*60*1000 etc.
Jul 1, 2011 at 12:39pm UTC
You could also make each time unit its own variable and subtract each.
for example...
int newHour, newMinute, newSecond, newMSecond;
int hour1 = 13;
int minute1 = 32;
etc....
int hour2 = 13;
int minute2 = 30;
etc....
newHour = hour1 - hour 2;
newMinute = minute1 - minute 2;
etc...
Jul 1, 2011 at 2:02pm UTC
Thank you guys but is there any standard function in C++ for carrying out such operations or to avoid doing it manually as much as possible?
Jul 1, 2011 at 2:09pm UTC
Last edited on Jul 1, 2011 at 2:10pm UTC
Jul 1, 2011 at 2:43pm UTC
Thanks toexii. Let me try this code