use Carbon\Carbon; // Create a new date object in the current timezone $date = Carbon::create(2022, 12, 25); // Output: 2022-12-25 00:00:00 echo $date->toDateTimeString();
use Carbon\Carbon; // Create a new date object $date = Carbon::create(2022, 12, 25); // Add 3 months and 2 days to the date $date->add(3, 'months')->add(2, 'days'); // Output: 2023-03-27 00:00:00 echo $date->toDateTimeString();
use Carbon\Carbon; // Create a new date object $date = Carbon::create(2022, 12, 25); // Format the date as "Saturday, December 25th 2022" echo $date->format('l, F jS Y');Package Library: Carbon is a package of the Nwidart Laravel Date library. It is a standalone package that can be used outside of Laravel as well.