I have a web application where users can insert the extra hours they have done. One problem I have is that I made a function in which I calculated the difference in hours. In the application, if a user has worked less or 4 hours, those hours are paid, instead if he has worked more than 4 hours, the user has the possibility to choose if he wants to be paid or turn them into a vacation day. The problem of the function is for example:
If user1 worked on Saturday from 8:00 to 12:10, the function should let me choose but it does not leave me because although I put it until 12:59 it counts it as 4 hours instead of 4:59 hours.
Here my function:
$datetime1 = new DateTime({FECHA_INICIO});
$datetime2 = new DateTime({FECHA_FIN});
$interval = $datetime1->diff($datetime2);
return $interval->format('%H:%I:%S');