use CarbonCarbon;
// Date = 7th of July 2021
$month = Carbon::now()->format('M'); // July
$month = Carbon::now()->format('m'); // 07
$month = Carbon::now()->month; // 7
<?php
namespace AppHttpControllers;
use IlluminateHttpRequest;
use CarbonCarbon;
class DateController extends Controller
{
public function index()
{
$currentDateTime = Carbon::now();
$newDateTime = Carbon::now()->addMonth();
print_r($currentDateTime);
print_r($newDateTime);
}
}
$period = CarbonPeriod::create($startDate, $endDate);
foreach($period as $date)
{
$dates[] = $date->format('d-m-Y');
}
$now = Carbon::now();
echo $now->year;
echo $now->month;
echo $now->weekOfYear;