dsimib1625 2014-01-13 08:06
浏览 11

too long

I want to find the time for first monday after say 10 months, something like this:-

   $start = time();
   echo date('l jS \of F Y h:i:s A', $start), PHP_EOL;
   $start = strtotime('first Monday +10 month', $start);
   echo date('l jS \of F Y h:i:s A', $start), PHP_EOL;

The result is:-

Monday 13th of January 2014 08:04:28 AM
Thursday 13th of November 2014 12:00:00 AM

Why is the first string not applied?

  • 写回答

1条回答 默认 最新

  • douzhan1963 2014-01-13 08:13
    关注

    I tested this code:

    <?php
    echo date('l jS \of F Y h:i:s A', strtotime('first monday of +10 month'));
    ?>
    

    And got the result -- all I had to do was add "of" to the string. Notes on the site indicate this is for >=5.3.

    Output:

    Monday 3rd of November 2014 12:00:00 AM
    

    Edit Ignore all this BS

    It's because you missed the note in the documentation. It applies

    Relative statements are always processed after non-relative statements

    So, it's going to the first Monday and then going forward 10 months.

    Edit: Strike this: Change the order to '+10 months first Monday' to get what you desire. I misread the note, too. I guess it means you need to do 2 strtotimes in the order you need.

    评论

报告相同问题?

悬赏问题

  • ¥20 易康econgnition精度验证
  • ¥15 线程问题判断多次进入
  • ¥15 msix packaging tool打包问题
  • ¥28 微信小程序开发页面布局没问题,真机调试的时候页面布局就乱了
  • ¥15 python的qt5界面
  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致