$date1 = getdate(strtotime('2013-12-31')); $date11 = getdate(strtotime('2014-01-01')); $date2 = getdate(strtotime('2012-12-31')); print_r($date1); echo " "; print_r($date2); echo " "; //判断两天是否相连 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是连续的两天 "; } if(isDiffDays($date1,$date2)){ echo "2013-12-31和2012-12-31不是同一天 "; }