繁体   English   中英

使用PHP gmdate()的每月第3天的最后一天

[英]3rd Last Day of the Month using PHP gmdate()

是否可以使用以下方法计算每月的第三天?

echo gmdate('Y-m-d H:i:s' , mktime({what goes here}));

我想要的结果的一些示例:

  1. 1月28日
  2. 2月25日/ 26日
  3. 3月28日
  4. 4月27日
  5. 5月29日
  6. 6月27日
  7. 7月28日
  8. 8月28日
  9. 9月27日
  10. 10月28日
  11. 11月27日
  12. 12月28日
$year = 2014;

foreach(range(1,12) as $month) {
    $time = gmdate("F jS",strtotime('-3 days',strtotime(date("Y-$month-t",strtotime("$year-$month-01")))));
    print $time . "\n";
}

产量

January 28th
February 25th
March 28th
April 27th
May 28th
June 27th
July 28th
August 28th
September 27th
October 28th
November 27th
December 28th

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM