Completely untested, without any varatny
<?php
$time1 = new DateTime("11:00");
$time2 = new DateTime("15:00");
$date1 = new DateTime("2014-01-10");
$date2 = new DateTime("2014-01-13");
$start = new DateTime("9:00");
$end = new DateTime("16:00");
$maxperday = $end->diff($start)->format("%h");
$full_day_hours = ($date2->diff($date1)->format("%a")-1)*$maxperday;
$first_day_hours = min($maxperday,max(0,$end->diff($time1)->format("%h")));
$last_day_hours = min($maxperday,max(0,$time2->diff($start)->format("%h")));
$hours = $first_day_hours + $full_day_hours + $last_day_hours;
?>
EDIT: Tested now, corrected two errors, seems to work now.