noblemfd
1 month ago
223
6
Laravel

How to force date format to dd/mm/yyyy

Posted 1 month ago by noblemfd

In my Laravel-5.8 project, I have this code:

Model

  protected $fillable = [
              'name',
              'start_date',
              'end_date',
          ];

protected $dates = [
    'start_date',
    'end_date'
    ];

View:

  <td>
     <input type="date" name="start_date[]" placeholder="dd/mm/yyyy" class="form-control start_date" min="{{Carbon\Carbon::now()->firstOfYear()->format('Y-m-d')}}" max="{{Carbon\Carbon::now()->lastOfYear()->format('Y-m-d')}}">
  </td>

  <td>
     <input type="date" name="end_date[]" placeholder="dd/mm/yyyy" class="form-control end_date" min="{{Carbon\Carbon::now()->firstOfYear()->format('Y-m-d')}}" max="{{Carbon\Carbon::now()->lastOfYear()->format('Y-m-d')}}">
     </td>

With this, I expected the date to display as dd/mm/yyyy, but it still comes as mm/dd/yyyy

Some systems display it as dd/mm/yyyy while others as mm/dd/yyyy

However, I want it to be:

dd/mm/yyyy

How do I resolve this?

Thank you

Please sign in or create an account to participate in this conversation.