PHP 检查等式中的下一个日期
以下代码应该检查下个月的第一个星期六,从中删除 6 天,并确定今天的日期是否小于计算得出的日期。它不起作用。无论今天的日期是否超过下个月的第一个星期六(6 天),IF 语句都会触发。
<?php $monthdate = date('Y-m-d', strtotime('-6 day', strtotime('first saturday', strtotime('+1 month'))));
if ($monthdate < date)
有什么想法吗?
奇妙
The following code is supposed to check for the first saturday of next month the remove 6 days from it and determine if that todays date is less than that date calculated. It is not working. The IF statement is triggering regardless of whether todays date has exceeded the first saturday of next month - 6 days or not.
<?php $monthdate = date('Y-m-d', strtotime('-6 day', strtotime('first saturday', strtotime('+1 month'))));
if ($monthdate < date)
Any ideas?
Marvellous
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
两个函数之间存在冲突,并且日期格式未正确设置为时间戳。对于社区我给出答案。
$monthdate
返回下个月第一个星期六的 UNIX 时间戳。需要使用函数strtotime(date("01-mY"))
来确保今天的日期是否比下个月的第一个星期六更高。如果本月的第一个星期六是 5 号,下个月是 2 号,则将 2 号作为第一个星期六,而不是 9 号。对从哪里开始搜索进行简单的数学调整。然后减去 8 天,并与当前日期和时间 time() 的 UNIX 时间戳进行比较;
目的
提供在第一个星期六接受预订的在线预订日历每个月的。
There was a conflict between 2 functions and also the date not being properly formatted as a time stamp. For the community I give the answer.
$monthdate
returns a UNIX timestamp of the first saturday of next month. The functionstrtotime(date("01-m-Y"))
is required to make sure that if todays date is higher in day terms the first saturday of the next month ie. if the first saturday of this month is the 5th and next month the 2nd, that it gets the 2nd as the first saturday not the 9th. Simple mathmatical adjustment of where to begin its search.This is then subtracted by 8 days and compared with a UNIX timestamp of the current date and
time time();
Purpose
Providing an online booking calendar that takes bookings on the first saturday of each month.