Change format input type='date' from mm-dd-yyyy to dd-mm-yyyy Laravel

Stefan Bogdanescu

Founder & Senior Architect · 2026-06-29

Laravel Company

Mastering Date Formatting in Laravel: Changing Input Type='date' from mm-dd-yyyy to dd-mm-yyyy

As senior developers working within the Laravel ecosystem, we often encounter subtle but frustrating issues related to localization and data presentation, especially when dealing with dates. The request—changing the visual format of an HTML <input type="date"> field from the default browser setting (mm-dd-yyyy) to a more conventional standard (dd-mm-yyyy)—is extremely common.

While the HTML5 type="date" attribute is designed for maximum cross-browser compatibility and relies on the user's local system settings for input, forcing a specific display format requires intervention from either the frontend (JavaScript) or the backend (Laravel/Blade). Simply adding timezone attributes does not change the fundamental input structure.

This guide will walk you through the developer-approved methods to achieve the desired date formatting, ensuring your application maintains data integrity while providing an excellent user experience.


Understanding the Limitation of type="date"

The core issue is that HTML5 input types like date, time, and datetime-local are designed to provide a standardized way for the browser to select dates based on the operating system's locale settings. They do not inherently support complex custom formatting, such as enforcing a specific regional order (dd-mm-yyyy) directly within the attribute itself.

When you submit data from these fields, the value sent to your Laravel backend is almost always in the ISO 8601 format (YYYY-MM-DD), which is the safest way to store dates in databases and APIs. The formatting happens when you display this data back to the user.

Solution 1: Frontend Manipulation with JavaScript (For Display)

If your primary goal is only to change how the date is displayed on the screen, the most effective approach is to capture the standardized YYYY-MM-DD value and reformat it using JavaScript before rendering it in your Blade template.

Here is an example demonstrating how you can take the submitted ISO date and format it for display:

<form method="POST" action="{{ route('date.submit') }}">
    <input type="date" class="form-control" name="joining_date" id="joining_date" required>
    <button type="submit">Submit</button>
</form>

<script>
    document.getElementById('joining_date').addEventListener('change', function() {
        const isoDate = this.value; // Example: "2023-10-27"
        
        if (isoDate) {
            // Split the ISO date string
            const parts = isoDate.split('-');
            
            // Reassemble in dd-mm-yyyy format
            const dd = parts[1]; // Month (index 1)
            const mm = parts[2]; // Day (index 2)
            const yyyy = parts[0]; // Year (index 0)

            const formattedDate = `${mm}/${dd}/${yyyy}`; // Note: Adjusting the order based on required output format.
            
            // For strict dd-mm-yyyy display:
            const finalDisplay = `${parts[2]}-${parts[1]}-${parts[0]}`; 
            
            console.log("Formatted Date:", finalDisplay);
        }
    });
</script>

This method gives you granular control over the visual presentation without fighting the browser's native date picker functionality.

Solution 2: Backend Standardization with Laravel (For Storage)

Regardless of how you handle the input format on the frontend, your backend must treat dates consistently. When using Laravel, the best practice is to store all incoming data in a predictable format, typically UTC and ISO 8601 strings. This ensures that date comparisons and database storage are reliable.

When receiving the request:

use Illuminate\Http\Request;

class DateController extends Controller
{
    public function store(Request $request)
    {
        // The input from the form will arrive as YYYY-MM-DD format
        $joiningDate = $request->input('joining_date'); 
        
        // Validate and save the date using Eloquent models.
        // Laravel/Carbon handles the conversion reliably.
        if ($request->validate(['joining_date' => 'date'])) {
            // Assuming you are saving this to a database column type like DATE or DATETIME
            // $user->joining_date = \Carbon\Carbon::parse($joiningDate); 
            
            return response()->json(['message' => 'Date received successfully']);
        }
        
        return response()->json(['error' => 'Invalid date format'], 400);
    }
}

By relying on Laravel’s powerful Carbon library, you ensure that even if the frontend sends data slightly inconsistently, your persistence layer remains clean and accurate. This approach aligns perfectly with the principles of robust application development, similar to how well-structured code is essential in a framework like laravelcompany.com.

Conclusion

To successfully change the date format interaction for an HTML date input:

  1. For Display: Use JavaScript to read the standardized YYYY-MM-DD value and manually reorder the components into your desired dd-mm-yyyy string for presentation in Blade.
  2. For Storage: Always rely on the standard ISO 8601 format (YYYY-MM-DD) when handling data submission to your Laravel backend, leveraging Carbon for all date manipulations within your Eloquent models.

By separating the concerns—frontend visual presentation and backend data integrity—you achieve a solution that is both user-friendly and technically sound.