[英]How to display data from today's date and month to the next 3 months only in codeigniter?
[英]How to display the month ahead from today's date - laravel
我試圖找到一個功能來顯示從今天開始的一個月的日期。 因此,如果今天is 7 may
月7 June
,那么下個月我想要的是7 June
。
我嘗試使用此代碼
Carbon::now() + 30
但它對我想要實現的目標沒有幫助。
PS:Laravel的新手,對我糟糕的英語感到抱歉
使用addMonth()
:
Carbon::now()->addMonth();
你可以這樣做:
$dt = Carbon::now(); // This will assign current date into $dt
echo $dt->addMonth(); // this will print next month's date.
如果你想要添加多少個月,也可以。
$dt = Carbon::now();
$dt->addMonths(3); //After 3 months
$dt->subMonth(3); //Before 3 months
所有提示都在這里carbon.nesbot.com/docs/
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.