strtotime是一个非常强大的函数。

传入的参数,详见官网的介绍

 

本月最后一个周日

echo date('Y-m-d',strtotime('last sunday of this month'));

下个月第三个周日

echo date('Y-m-d',strtotime('third sunday of next month'));

下个月的最后一天

echo date('Y-m-d',strtotime('last day of next month'));

第28周的星期日的日期

date('Y-m-d', strtotime('2014-W28-7'));

注意:

1. 获取本年的最后一天 strtotime('last day of this year') 是不起作用的,因为 last day of 只对月起作用。正确的方法date('Y-m-d',strToTime('1/1 next year -1 day'));

 

另附:

// the first day in this week,it's Monday
$thisMonday = date('Y-m-d', time() - 86400*date('w') + 86400);
// the last day in this week,it's Friday
$thisFriday   = date('Y-m-d', time() - 86400*date('w') + 86400*5);

相关文章:

  • 2021-12-11
  • 2022-12-23
  • 2022-02-01
  • 2022-12-23
  • 2021-12-04
  • 2021-07-30
  • 2021-07-15
  • 2021-07-24
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-05-18
  • 2022-01-04
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案