ludah Posted May 5, 2015 Share Posted May 5, 2015 Please Can someone help me on this Am creating a timetable system and i want to check only the time difference Am collect a time only from the html form thus $startTime = 13:30:00 $endTime = 14:00:00 How can i find the deference between this time from the html in php. Thanks Quote Link to comment Share on other sites More sharing options...
Barand Posted May 5, 2015 Share Posted May 5, 2015 Use DateTime class. $startTime = '13:30:00'; $endTime = '14:00:00'; $dt1 = new DateTime($startTime); $dt2 = new DateTime($endTime); $diff = $dt1->diff($dt2); echo $diff->format('%h:%I'); //--> 0:30 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.