- Use below codes for get month name from date. This code can use in Laravel language in controller or blade file. If you want to use this code in laravel blade file you must put this code in @php @endphp.
Example 1:
<?php
namespace App\Http\Controllers;
use Carbon\Carbon;
class SignaturePadController extends Controller
{
/**
* Write code on Method
*
* @return response()
*/
public function index()
{
$myDate = '01/07/2020';
$date = Carbon::createFromFormat('m/d/Y', $myDate);
$monthName = $date->format('F');
var_dump($monthName);
}
}
Output : July
Example 2:
<?php
namespace App\Http\Controllers;
use Carbon\Carbon;
class SignaturePadController extends Controller
{
/**
* Write code on Method
*
* @return response()
*/
public function index()
{
$date = Carbon::now();
$monthName = $date->format('F');
var_dump($monthName);
}
}
Output : December
Thanks for your blog, nice to read. Do not stop.