2017-03-09 114 views

回答

3

今年3月有第一周有天,而不是4天;星期三从星期一到星期日的第五周在本月的这一侧进行第一周。

因此,你可以简单地用每个月的第一个星期日的日期来实现你的结果

$first_sunday = new DateTime('first sunday of this month'); 
echo $first_sunday->format("j"); // Output: 5 for March 2017 
+0

感谢您的帮助@Qirel。我在哪里可以找到有关该文件的文件? –

+0

[PHP DateTime类](http://php.net/manual/en/class.datetime.php)是一个很好的开始:-) – Qirel

相关问题