Get current date automatically in a form in laravel 5
I want to display the current date in the date_created field when clicked to create the page.
{!! Form::open(['route'=>'articles.store'])!!}
<div class="form-group">
<label><b>DATE CREATED</b></label>
{!! Form::text('date_created',null,array('class'=>'form-control date-picker')) !!}
</div>
{!! form::submit('Add',[' class'=>'btn btn-primary form-control'])!!}
{!! Form::close()!!}
+3
source to share
4 answers
Use Carbon to assign time and date in Laravel
Carbon is officially supported by Laravel
Here you can print today date with Carbon.
{!! Form::open(['route'=>'articles.store'])!!}
<div class="form-group">
<label><b>DATE CREATED</b></label>
{!! Form::text('date_created',Carbon\Carbon::today()->toDateString(),array('class'=>'form-control date-picker')) !!}
</div>
{!! form::submit('Add',[' class'=>'btn btn-primary form-control'])!!}
{!! Form::close()!!}
0
source to share