For example, I have first time 11:32:48 and second is 5:12:53 . Format is Hours:minutes:seconds I need to do 11:32:48-5:12:53=xx:xx:xx with PHP. Can anyone help me? Do I need to convert it to seconds?
easy if you can use explode. $time1 = 11:32:48; $time2 = 5:12:53; $time1 = explode(':',$time1); $time2 = explode(':',$time2); $result[0] = $time1[0] - $time2[0]; $result[1] = $time1[1] - $time2[1]; $result[2] = $time1[2] - $time2[2]; $difference = $result[0].':'.$result[1].':'.$result[2]; PHP: Obviously you can simplify this quite a bit but you should get the idea. $difference will be the result. Only thing to take note of, make sure you can differentiate between AM/PM. To most easily do this, make sure that the hours are in 24-hour mode and not 12-hour mode. Hope that helps!