How to display the name of day for current date in laravel 5.3?

Viewed 3706

I want to print the name of the current date in laravel 5.3. I can get the current date in following ways:

     <?php use Carbon\Carbon;
$carbon=Carbon::now();
              echo $carbon->day;?>

The above code prints 25 but I want it to print Thursday.How should I do that??

3 Answers

Carbon::now()->format('l') works but I would recommend using

Carbon::now()->formatLocalized('%A')

seeing that this would translate the day string according to the current set locale in case your app is going support internationalization.

After Laravel 5.5 you can use now() function to get the current date and time.

In blade file, you can write like this to print name of current day.

{{  now()->format('l') }}

enter image description here

Related