PHP检查等式中的下一个日期
下面的代码应该检查下个月的第一个星期六,从中删除6天,并确定今天的日期是否小于计算的日期。它不起作用。无论今天的日期是否超过下个月的第一个星期六(6天),都会触发IF语句PHP检查等式中的下一个日期,php,date,strtotime,Php,Date,Strtotime,下面的代码应该检查下个月的第一个星期六,从中删除6天,并确定今天的日期是否小于计算的日期。它不起作用。无论今天的日期是否超过下个月的第一个星期六(6天),都会触发IF语句 <?php $monthdate = date('Y-m-d', strtotime('-6 day', strtotime('first saturday', strtotime('+1 month')))); if ($monthdate < date) 两个函数之间存在冲突,并且日期未正确格式化为时间戳
<?php $monthdate = date('Y-m-d', strtotime('-6 day', strtotime('first saturday', strtotime('+1 month'))));
if ($monthdate < date)
两个函数之间存在冲突,并且日期未正确格式化为时间戳。对于社区,我给出了答案
<?php $monthdate = date(strtotime('first saturday', strtotime('-8 day', strtotime('+1 month', strtotime(date("01-m-Y"))))));
if ($monthdate < time())
有没有想过将结果打印出来,而不仅仅是在if语句中检查它?以及所有中间结果,以查看它们是否返回非预期值?var\u dump($monthdate)
和var\u dump($date)
值不是时间戳,这就是问题所在$monthdate应该是UNIX时间戳,我如何使它成为UNIX时间戳。日期应该是今天的日期,作为UNIX时间戳,而不是。有什么想法吗?date
是一个常量。这是你在这里做的错字吗?如果没有,那么如果您将error\u reporting
设置为E|u ALL | E_STRICT
并打开错误显示,您就会收到通知(或者是警告?)。(认为这是一个暗示;-))。