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 阅读(6848) 评论(0) 编辑 收藏 举报
【推荐】还在用 ECharts 开发大屏?试试这款永久免费的开源 BI 工具!
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步