dongpu3792 2011-03-30 11:26
浏览 22

PHP检查等式中的下一个日期

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

  • 写回答

1条回答 默认 最新

  • douyou7797 2011-03-30 12:06
    关注

    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.

    <?php $monthdate = date(strtotime('first saturday', strtotime('-8 day', strtotime('+1 month', strtotime(date("01-m-Y")))))); 
    
    if ($monthdate < time())
    

    $monthdate returns a UNIX timestamp of the first saturday of next month. The function strtotime(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.

    评论

报告相同问题?

悬赏问题

  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥16 mybatis的代理对象无法通过@Autowired装填
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂
  • ¥15 wordpress 产品图片 GIF 没法显示
  • ¥15 求三国群英传pl国战时间的修改方法
  • ¥15 matlab代码代写,需写出详细代码,代价私
  • ¥15 ROS系统搭建请教(跨境电商用途)