Laravel-在编辑表单中显示DateTime值 [英] Laravel - Display DateTime Value in Edit Form

查看:490
本文介绍了Laravel-在编辑表单中显示DateTime值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在我的编辑表单中显示作为DateTime值的数据?

input="datetime-local."

这是我的DateTime值的样子:2018-04-02 04:04:00.

我希望它显示在此输入中:

<input type="datetime-local" name="flight_date" class="form-control">

我的 $ variable->数据

$aircraftFlight->flight_date

编辑 VAR DUMP

object(App \ AircraftFlights)#527(26){[表格":受保护的] => 字符串(16)"aircraft_flights" ["primaryKey"] =>字符串(2)"id" ["timestamps"] => bool(false)["connection":protected] => string(5) "mysql" ["keyType":受保护] => string(3)"int" ["incrementing"] => bool(true)["with":protected] => array(0){} ["withCount":protected] => array(0){} ["perPage":protected] => int(15)["exists"] => bool(true) ["wasRecentlyCreated"] => bool(false)["attributes":protected] => array(9){["id"] => int(1)["flight_number"] =>字符串(10)"AA-0000003" ["iata_flight_number"] =>字符串(5)"ABCD2" ["flight_date"] => 字符串(19)"2018-04-02 04:04:00" ["departure_time"] =>字符串(19) "2018-05-04 01:59:00" ["arrival_time"] => string(19)"2018-05-05 13:59:00"[" from_location] =>字符串(11)"阿富汗 [目的地"] =>字符串(7)阿尔巴尼亚" ["aircraft_id"] => int(1)} [原始":受保护的] => array(9){[" id] => int(1) ["flight_number"] =>字符串(10)"AA-0000003" ["iata_flight_number"] => string(5)"ABCD2" ["flight_date"] => string(19)"2018-04-02 04:04:00" ["departure_time"] =>字符串(19)"2018-05-04 01:59:00" ["arrival_time"] =>字符串(19)"2018-05-05 13:59:00" ["from_location"] =>字符串(11)阿富汗" [目的地"] => string(7)"Albania" ["aircraft_id"] => int(1)} ["changes":受保护] => array(0){} ["casts":受保护的] => array(0){} ["dates":protected] => array(0){} ["dateFormat":受保护的] => NULL ["appends":受保护的] => array(0){} ["dispatchesEvents":protected] => array(0){} ["observables":受保护的] => array(0){} ["relations":受保护的] => array(0){} ["touches":受保护] => array(0){} [隐藏":受保护] => array(0){} [可见":受保护] => array(0){ } ["fillable":受保护] => array(0){} ["guarded":受保护] => array(1){[0] =>字符串(1)"*"}}

解决方案

我将使用日期时间选择器,其输入类型为文本,并将id设置为flight_date

看看这个:

https://eonasdan.github.io/bootstrap-datetimepicker/

这是我遇到的第一个数字

希望这会有所帮助

更新

这是我们在工作中使用的,我知道它是有效的

https://www.eyecon.ro/bootstrap-datepicker/

尝试一下.

How can I display my data which is a DateTime value in my edit form?

input="datetime-local."

Here's what my DateTime value looks like: 2018-04-02 04:04:00.

I want it to display in this input:

<input type="datetime-local" name="flight_date" class="form-control">

my $variable->data

$aircraftFlight->flight_date

EDIT VAR DUMP

object(App\AircraftFlights)#527 (26) { ["table":protected]=> string(16) "aircraft_flights" ["primaryKey"]=> string(2) "id" ["timestamps"]=> bool(false) ["connection":protected]=> string(5) "mysql" ["keyType":protected]=> string(3) "int" ["incrementing"]=> bool(true) ["with":protected]=> array(0) { } ["withCount":protected]=> array(0) { } ["perPage":protected]=> int(15) ["exists"]=> bool(true) ["wasRecentlyCreated"]=> bool(false) ["attributes":protected]=> array(9) { ["id"]=> int(1) ["flight_number"]=> string(10) "AA-0000003" ["iata_flight_number"]=> string(5) "ABCD2" ["flight_date"]=> string(19) "2018-04-02 04:04:00" ["departure_time"]=> string(19) "2018-05-04 01:59:00" ["arrival_time"]=> string(19) "2018-05-05 13:59:00" ["from_location"]=> string(11) "Afghanistan" ["destination"]=> string(7) "Albania" ["aircraft_id"]=> int(1) } ["original":protected]=> array(9) { ["id"]=> int(1) ["flight_number"]=> string(10) "AA-0000003" ["iata_flight_number"]=> string(5) "ABCD2" ["flight_date"]=> string(19) "2018-04-02 04:04:00" ["departure_time"]=> string(19) "2018-05-04 01:59:00" ["arrival_time"]=> string(19) "2018-05-05 13:59:00" ["from_location"]=> string(11) "Afghanistan" ["destination"]=> string(7) "Albania" ["aircraft_id"]=> int(1) } ["changes":protected]=> array(0) { } ["casts":protected]=> array(0) { } ["dates":protected]=> array(0) { } ["dateFormat":protected]=> NULL ["appends":protected]=> array(0) { } ["dispatchesEvents":protected]=> array(0) { } ["observables":protected]=> array(0) { } ["relations":protected]=> array(0) { } ["touches":protected]=> array(0) { } ["hidden":protected]=> array(0) { } ["visible":protected]=> array(0) { } ["fillable":protected]=> array(0) { } ["guarded":protected]=> array(1) { [0]=> string(1) "*" } }

解决方案

I would use a date time picker with the input type as text and set the id to flight_date

have a look at this one:

https://eonasdan.github.io/bootstrap-datetimepicker/

There are a number around this is just the first I came across

Hope this helps

Update

This is the one that we use at work and I know it works

https://www.eyecon.ro/bootstrap-datepicker/

Try that.

这篇关于Laravel-在编辑表单中显示DateTime值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆