使用m-d-Y格式时,如何找到2个日期(以天为单位)的差异?

I need something like this

$today = date("m-d-Y");
$otherdate = "05-03-2013";

//Some math here

//echo the difference between the two dates in days

I've tried using strtotime but it doesn't work correctly and usually says something like the difference was somewhere around 15k days (which obviously isn't right)

Any help?

Try this for Y-m-d format date

$now = strtotime(date("Y-m-d")); // or your date as well
$otherdate = strtotime("2013-05-03");
$datediff = $now - $otherdate;
echo floor($datediff/(60*60*24)). "Days";

PHP 5.3+

$b_date1 = new DateTime($date);
$today1 = new DateTime($today);
$interval = date_diff($today1,$b_date1);

PHP version less than 5.2

Or

function date_diff1($date1, $date2) { 
    $current = $date1; 
    $datetime2 = date_create($date2); 
    $count = 0; 
    while(date_create($current) < $datetime2){ 
        $current = gmdate("Y-m-d", strtotime("+1 day", strtotime($current))); 
        $count++; 
    } 
    return $count; 
}

Try diff() method of DateTime:

$now  = new DateTime();
$then = DateTime::createFromFormat('m-d-Y', '05-03-2013');

$interval = $now->diff($then);

$days = $interval->format('%a days');