I have used a function to calculate date difference between 2 dates.
Here is my function
function date_difference ($date_1, $date_2) {   
    $val_1 = new DateTime($date_1);
    $val_2 = new DateTime($date_2);
    $interval = $val_1->diff($val_2);
    $year     = $interval->y;
    $month    = $interval->m;
    $day      = $interval->d;
    $output   = '';
    if($year > 0){
        if ($year > 1){
            $output .= $year." years ";     
        } else {
            $output .= $year." year ";
        }
    }
    if($month > 0){
        if ($month > 1){
            $output .= $month." months ";       
        } else {
            $output .= $month." month ";
        }
    }
    if($day > 0){
        if ($day > 1){
            $output .= $day." days ";       
        } else {
            $output .= $day." day ";
        }
    }
    if($day == 0)
        $output.=' Almost Over';
    if($day < 0)
        $output.= ' Expired';
    return $output;
}
I am using it like this
echo date_difference(date('m/d/Y'),'02/06/2013');
It shows the result as 25 days where as it should show expired. Can anyone point where i am doing wrong.
 
    
 
     
     
    