Laravel 到 form::time - Carbon 的集体绑定时间
Laravel collective binding time to form::time - Carbon
我尝试使用 3 种不同的样式进行绑定,但 none 中的样式按预期工作:
示例日期时间:2018-03-02 23:00:00
//using h:i:s A ---> Nothing shown
{!! Form::time('field_name', \Carbon\Carbon::parse($user->relation->col_name)->format('h:i:s A'), ['class'=>'form-control']) !!}
//using h:i A ----> Nothing shown
{!! Form::time('field_name', \Carbon\Carbon::parse($user->relation->col_name)->format('h:i A'), ['class'=>'form-control']) !!}
//using h:i:s ----> Shows time but AM/PM does not work
{!! Form::time('field_name', \Carbon\Carbon::parse($user->relation->col_name)->format('h:i:s'), ['class'=>'form-control']) !!}
//using strtotime -----> same results like above
{!! Form::time('field_name', date('h:i:s A', strtotime($user->relation->col_name)), ['class'=>'form-control']) !!}
知道如何将 23:00:00 绑定到 AM PM 吗?
第一种方法给出如下内容:
time
输入类型属性支持 H:i
或 H:i:s
(PHP)。浏览器稍后决定它的显示方式。如果您插入的格式无效,则预设值将为空。
The value of the time input is always in 24-hour format: "hh:mm", regardless of the input format, which is likely to be selected based on the user's locale (or by the user agent). If the time includes seconds (see Using the step attribute), the format is always "hh:mm:ss".
可在 MDN 上获得更多详细信息。
我尝试使用 3 种不同的样式进行绑定,但 none 中的样式按预期工作:
示例日期时间:2018-03-02 23:00:00
//using h:i:s A ---> Nothing shown
{!! Form::time('field_name', \Carbon\Carbon::parse($user->relation->col_name)->format('h:i:s A'), ['class'=>'form-control']) !!}
//using h:i A ----> Nothing shown
{!! Form::time('field_name', \Carbon\Carbon::parse($user->relation->col_name)->format('h:i A'), ['class'=>'form-control']) !!}
//using h:i:s ----> Shows time but AM/PM does not work
{!! Form::time('field_name', \Carbon\Carbon::parse($user->relation->col_name)->format('h:i:s'), ['class'=>'form-control']) !!}
//using strtotime -----> same results like above
{!! Form::time('field_name', date('h:i:s A', strtotime($user->relation->col_name)), ['class'=>'form-control']) !!}
知道如何将 23:00:00 绑定到 AM PM 吗?
第一种方法给出如下内容:
time
输入类型属性支持 H:i
或 H:i:s
(PHP)。浏览器稍后决定它的显示方式。如果您插入的格式无效,则预设值将为空。
The value of the time input is always in 24-hour format: "hh:mm", regardless of the input format, which is likely to be selected based on the user's locale (or by the user agent). If the time includes seconds (see Using the step attribute), the format is always "hh:mm:ss".
可在 MDN 上获得更多详细信息。