1

I have a date input field in laravel. I want the date format to be "D/M/Y". This gets the today's date but i want to be in correct format and when selecting a date.

{{Form::date('name', \Carbon\Carbon::now(), array('class' => 'form-control', 'required' => '')) }}
AddWeb Solution Pvt Ltd
  • 21,025
  • 5
  • 26
  • 57
steven
  • 147
  • 1
  • 4
  • 12

3 Answers3

0

If you want to display this format by default, use format() method:

{!! Form::date('name', \Carbon\Carbon::now()->format('D/M/Y'), ['class' => 'form-control', 'required' => true]) !!}

If you want to format user input you need to use JS library like jQuery Datepicker for that. It has such an option.

Alexey Mezenin
  • 158,981
  • 26
  • 290
  • 279
0

Actually there is no out of the box solution for formatting date type. You can try to do it with JS to format that field on change.

Buglinjo
  • 2,067
  • 1
  • 15
  • 26
0

Try the below tested code, should work for you:

{{Form::text('name', Carbon\Carbon::parse('now')->format('D/M/Y'), array('class' => 'form-control', 'required' => '')) }}
AddWeb Solution Pvt Ltd
  • 21,025
  • 5
  • 26
  • 57