如何找到时间差异,如上午9点和下午1点

i have two times for example start up time as 9.00 AM and end time as 1.00 PM and i m getting this two times from a dropdown list.How to find the difference between this two times in hours only..

$to_time = strtotime("09:00:00");
$from_time = strtotime("13:00:00");
echo round(abs($to_time - $from_time) / 60 / 60 ,2). " Hours";

In case you are not sure you can convert your time in 24hr format using

$time_in_24_hour_format  = date("H:i", strtotime("1:00 PM"));