[英]Get very first week day of a new month in carbon php
Hello please i am having problem in getting the start week date of next month using php carbon.您好,我在使用 php carbon 获取下个月的开始周日期时遇到问题。 I try the below code with out the start of the current month not the added month.
我在没有当月的开始而不是添加的月份的情况下尝试下面的代码。
$carbon = new Carbon();
$thisMonth = $carbon::now()->startOfMonth();
$nextMonth = $thisMonth->addMonth();
echo $nextMonth->startOfWeek();
Out put of the above code上面代码的输出
2020-09-28 00:00:00
2020-09-28 00:00:00
Expectation: Today is 27 - 09 2020 i expected to output the first week day of the next month with is 01 - 10 -2020.预期:今天是 27 - 09 2020 我预计输出下个月的第一个工作日是 01 - 10 -2020。
I need to get the first date (Monday - Friday) of every next month from the current month when execute this code.执行此代码时,我需要从当前月份开始每个下个月的第一个日期(星期一 - 星期五)。
如果您想获得每个下个月的第一个日期,您可以试试这个:
now()->addMonthNoOverflow(1)->firstOfMonth()->dayName;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.