I try to add date and time into my database but I have probems:
First: I create a form:
<div class="row">
<div class="form-group col-md-6">
{!! Form::label('roba_spremna','The cargo is ready:') !!}
{!! Form::text('roba_spremna', null, ['class'=>'form-control']) !!}
</div>
<div class="form-group col-md-6">
{!! Form::label('auction_end','Auction close at:') !!}
{!! Form::text('auction_end', null, ['class'=>'form-control']) !!}
</div>
</div>
After that I add bootstrap-datetimepicker (js library):
$( document ).ready(function() {
$(function () {
$('#roba_spremna, #auction_end').datetimepicker();
});
});
and at Article model I write:
protected $fillable = [
'title',
'body',
'roba_spremna',
'auction_end'
];
protected $dates = [
'roba_spremna',
'auction_end'
];
public function setRobaSpremnaAttribute($date){
$this->attributes['roba_spremna']= Carbon::createFromFormat('Y-m-d', $date);
}
Now When I try to store date with time at my database so when I submit form I get this error:
InvalidArgumentException in Carbon.php line 425:
Unexpected data found.
Unexpected data found.
Trailing data
http://i.imgur.com/V1imBwC.png
How I can solve my problem?