What is the best (date format independent way) in PHP to calculate difference in days between two dates in specified format.
I tried the following function:
PHP 5.2 introduces the DateTime and DateInterval classes which makes this easy:
function get_date_offset($start_date, $end_date) { $start_time = new DateTime($start_date); $end_time = new DateTime($end_date); $interval = $end_time->diff($start_time); return $interval->format('%a days'); }