$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";

}

Logo

魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。

更多推荐