Change the date format in the blade file in Laravel

Do you want to use the Laravel blade date format in the Laravel application?

In this tutorial, I will give you an example of “How to Change the date format in the blade file in Laravel“, So you can easily apply it with your laravel 5, laravel 6, laravel 7, laravel 8 and laravel 9 application.

This step-by-step tutorial helps you learn change the date format in Laravel with the help of php date format function.

Change the date format in Laravel view page :

We can change the stored date format from our model, and controller, and directly in the blade file, In this example, we change the date format (‘d-m-y’) in our view blade file.

Preview: Before changing the date format

Change the date format in Laravel

Preview : After changing the date format

Change the date format in Laravel

We used <input type=”date” name=”dob”> in the add.blade.php file to store the date of birth value in the database.

change the date format in laravel view page

Now, we want to change the date format which is fetched from the database. now we got 1994-08-05 {{ $viewdata->dob }}.

<label>DOB:</label>
<span>{{ $viewdata->dob }}</span>

We can change or rearrange the format dd/mm/yyyy in the view blade file in Laravel.

 <label>DOB:</label>
 <span>{{  date('d-m-Y', strtotime($viewdata->dob)) }}</span> 
laravel date format dd/mm/yyyy

We can also modify the date format which is more readable and human-friendly (dd/month/yyyy) in the view blade file in Laravel.

<label>DOB:</label>
<span>{{  date('j \\ F Y', strtotime($viewdata->dob)) }}</span>
laravel date format dd/month/yyyy

I hope that this article helped you learn Laravel date format with Examples in Laravel. You may also want to check out our guide on how to change the date format in the entire laravel application using Macro defining once in the Laravel application.

Also Read: Get the day difference between the two dates in Laravel.

Hi, My name is Gaurav Pandey. I'm a Laravel developer, owner of 8Bityard. I live in Uttarakhand - India and I love to write tutorials and tips that can help other developers. I am a big fan of PHP, Javascript, JQuery, Laravel, WordPress. connect@8bityard.com

Scroll to Top