Difference between time only

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

here is an example code that would help you

$start = '13:30:00';
$end = '14:00:00';

$startDate = date_create_from_format('H:i:s', $start);
$endDate = date_create_from_format('H:i:s', $end);
print_r($startDate->diff($endDate));

this will output

DateInterval Object
(
[y] => 0
[m] => 0
[d] => 0
[h] => 0
[i] => 30
[s] => 0
[weekday] => 0
[weekday_behavior] => 0
[first_last_day_of] => 0
[invert] => 0
[days] => 0
[special_type] => 0
[special_amount] => 0
[have_weekday_relative] => 0
[have_special_relative] => 0
)

and then you can use the diff object to determine the difference

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.