I have a time 17:00:00 which is 5:00 PM and I subtract it into 12:00 Pm and the out put is always 5 which is wrong it should be 7 .
$overtime = round((abs(strtotime('17:00:00') - strtotime('12:00')) / 60) / 60, 2);
I have a time 17:00:00 which is 5:00 PM and I subtract it into 12:00 Pm and the out put is always 5 which is wrong it should be 7 .
$overtime = round((abs(strtotime('17:00:00') - strtotime('12:00')) / 60) / 60, 2);
It sounds like you are confusing 12:00 PM (noon) with 12:00 am (midnight). 17:00 is 7 hours away from midnight (12:00 AM or 24:00 (today) or 00:00 (tomorrow)).
According to 24-hour clock - Wikipedia:
Midnight 00:00 and 24:00
In the 24-hour time notation, the day begins at midnight, 00:00, and the last minute of the day begins at 23:59. Where convenient, the notation 24:00 may also be used to refer to midnight at the end of a given date[5] – that is, 24:00 of one day is the same time as 00:00 of the following day.
You want to subtract strtotime('24:00')