php日期的怎么判断同一天,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";
}
原文:http://www.cnblogs.com/liuwenbohhh/p/4451268.html
總結
以上是生活随笔為你收集整理的php日期的怎么判断同一天,php如何判断两个时间戳是一天的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 小马智行与美团达成战略合作,加速自动配送
- 下一篇: 19款宝来按两下锁车键会响吗(31省份2