use Carbon\Carbon; $date = Carbon::now(); $newDate = $date->addDay(); echo $newDate->format('Y-m-d'); // output: Current date + 1 day
use Carbon\Carbon; $date = Carbon::create(2021, 12, 31); $newDate = $date->addDay(); echo $newDate->format('Y-m-d'); // output: January 1, 2022In this example, we create a new Carbon instance with a specific date (December 31, 2021). We then use the `addDay()` method to add one day to the date. Finally, we format the new date using the `format()` method and output it to the screen. Package Library: Carbon