Laravel Collective date format

Norgul picture Norgul · Jun 22, 2017 · Viewed 10.1k times · Source

Is there a way to set Laravel Collective date picker format to yyyy-mm-dd?

I am using now:

{{ Form::date('deadline', null,['class' => 'form-control']) }}

but in the front end I get an input field with mm/dd/yyyy inside. I tried parsing the Carbon instance as second parameter, but that does nothing.

{{ Form::date('deadline', \Carbon\Carbon::now()->format('Y-m-d'),['class' => 'form-control']) }}

Answer

linktoahref picture linktoahref · Jun 22, 2017

You could pass an DateTime instance for the second parameter. As per the source code if the second parameter is an DateTime instance it would return the formatted date (Y-m-d).

So you could try this,

{{ Form::date('deadline', new \DateTime(), ['class' => 'form-control']) }}