php如何判断两个时间戳是一天

$date1 = getdate(strtotime('2013-12-31'));
$date11 = getdate(strtotime('2014-01-01'));
$date2 = getdate(strtotime('2012-12-31'));
print_r($date1);
echo "\n";
print_r($date2);
echo "\n";

//判断两天是否相连
function isStreakDays($last_date,$this_date){

    if(($last_date['year']===$this_date['year'])&&($this_date['yday']-$last_date['yday']===1)){
        return TURE;
    }elseif(($this_date['year']-$last_date['year']===1)&&($last_date['mon']-$this_date['mon']=11)&&($last_date['mday']-$this_date['mday']===30)){
        return TURE;
    }else{
        return FALSE;
    }
}
//判断两天是否是同一天
function isDiffDays($last_date,$this_date){

    if(($last_date['year']===$this_date['year'])&&($this_date['yday']===$last_date['yday'])){
        return FALSE;
    }else{
        return TRUE;
    }
}

if(isStreakDays($date1,$date11)){
    echo "2013-12-31和2014-01-01是连续的两天\n";
}

if(isDiffDays($date1,$date2)){
    echo "2013-12-31和2012-12-31不是同一天\n";
}

posted on 2015-04-23 17:49  liuwenbohhh  阅读(6838)  评论(0编辑  收藏  举报