0

我正在使用 Laravel5.2 和 LaravelCollective 表单和 html 助手。

我的数据库中有一个名为 fixture_date 的字段,它的类型为 datetime。

在我看来,我正在使用

{{ Form::label('fixture_date', 'Date:') }}
{{ Form::date('fixture_date', \Carbon\Carbon::now()) }}

这只会产生一个日期选择器,并在提交时将 2017-01-12 00:00:00 输入数据库。

如果我改变我的看法

{{ Form::label('fixture_date', 'Date:') }}
{{ Form::time('fixture_date', \Carbon\Carbon::now()) }}

我得到一个时间选择器,但是当我提交时,由于数据丢失(日期部分)而出现错误

有没有办法在该字段中获取日期时间选择器,因为我需要它来创建和更新。

谢谢

4

1 回答 1

3

尝试使用可用的格式方法:

{{ Form::time('fixture_date', Carbon\Carbon::now()->format('H:i')) }}因为时间字段默认需要这种 24 小时时间格式。

于 2017-01-14T13:49:13.540 回答