Change date format in blade template

Stefan Izdrail

Founder & Senior Architect · 2026-06-29

Laravel Company
Title: Efficiently Change Date Formats in Blade Templates using Laravel Introduction In web development, displaying dates in desired formats is an essential aspect when working with data. Laravel offers several ways to manipulate and format date values within your application. In this blog post, we'll focus on how we can transform a date printed in YYYY-MM-DD to DD--MM--YEAR or an English text like "5th May 2018" by making use of Laravel's built-in functions and Blade template language. Step 1: Understanding Date Formatting with Carbon Library Laravel utilizes the Carbon library for managing dates. It provides a robust set of date manipulation methods, including formatting dates into various formats. To access these functionalities, you can use the `use Carbon\Carbon` directive at the top of your controller or within your class if you're working with Laravel's Eloquent models. Step 2: Converting Date Formats using Carbon To convert a date from YYYY-MM-DD to DD--MM--YEAR format, follow these steps: 1. Create an instance of Carbon representing the desired date by passing the input date as the first argument. 2. Use the `format` method on this instance with the target formatting pattern (DD--MM--YEAR) as its first argument. 3. Optionally, you can also pass a timezone as the second argument to display dates in a specific location's time zone. 4. Assign the resulting string back to your variable where the date is currently printed. Code Example:
    $date = Carbon::parse($expenses->date);
$formattedDate = $date->format('d-m-Y'); // DD--MM--YEAR Format
$fullEnglishFormatDate = Str::title(Str::lower(Carbon::now()->toFormattedDateString().' '.$date->diffForHumans())); // 5th May 2018 Format
Step 3: Using Blade Template Language for Date Formatting In your Blade template, you can easily access the converted date format by using a combination of Laravel's Blade syntax and Carbon functions. Here's an example:
<td>{{date('j-m-Y', strtotime($expenses->date))}}</td>
Step 4: Combining Multiple Date Formats in a Single View If you need to display multiple date formats in your view, use the following code example:
<table>
    <tr>
        <td>{{date('Y-m-d', strtotime($expenses->date))}}</td>
        <td>{{date('j-m-Y', strtotime($expenses->date))}}</td>
    </tr>
    <tr>
        <td>{{Carbon::parse($expenses->date)->format('d-m-Y')}}</td>
        <td><a href="{{route('invoice.show', $inv->id)}}">View Invoice Date: {{Carbon::parse($inv->invoice_date)->toFormattedDateString()}}</a></td>
    </tr>
</table>
Conclusion In summary, working with date formats in Laravel using Blade templates is fairly straightforward. By using the Carbon library and understanding how to manipulate dates and formats, you can efficiently transform a given date into different styles. This flexibility allows you to create cleaner views that present data in a user-friendly manner while maintaining functionality. Remember to keep your code well structured with proper naming conventions and use natural backlinks whenever applicable for better readability and organization.