[英]PHP Carbon Add Month But Fixed Date
I want to create a fixed date, but the month keep increment 我想创建一个固定的日期,但是月份保持递增
$now = Carbon::now(); // 2019-03-12
I already try using Carbon::now()->addMonth(1)
but its just adding one month and not fixed the date. 我已经尝试使用
Carbon::now()->addMonth(1)
但Carbon::now()->addMonth(1)
添加了一个月而未确定日期。
what i expected from the output is 2019-04-25 the date is fixed to 25 我从输出中期望的是2019-04-25日期固定为25
Can i addMonth(1)
but fixed the date to 25 ?? 我可以添加
addMonth(1)
但将日期固定为25吗?
$date = Carbon::now(); // 2019-03-12
$date->day(25)->addMonth(1);
我不太了解,但也许您正在寻找:
$date = Carbon::create(2019, 4, 25);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.