【发布时间】:2018-08-29 18:42:48
【问题描述】:
我使用 date() 格式返回一个月的起始工作日。我下面的代码是我试图实现这一目标的方式。对于本年度(2018 年),这一切正常。例如,本月是 8 月,开始的工作日是星期三,因此它将返回 3 表示星期三。 (目前有效)
随着我们将年份提前到 2019 年,开始的工作日开始出现错误。 例如,2019 年 1 月从星期二开始,所以它应该返回 2 但返回 1。(一天)
这个错误似乎是累积的,所以如果我们到 2020 年,那么它是 2 天等等。 我已经非常努力地正确格式化此 Date() 但无济于事。这甚至是正确的方法吗?
代码:
$future_month = 5 /*for January 2019*/
$starting_weekday = date('N',mktime(0, 0, 0, date('m', strtotime('+'.$future_month.' months', strtotime(date('Y-m-01')))), 1));
非常感谢
卡梅隆
【问题讨论】: