我想将日期设置为我的html日期字段。我在Laravel中使用过mutator,现在如何在日期字段中设置日期来编辑记录?

问题描述 投票:2回答:1

这是我模型中的My mutator。

protected $dates = ['closer_date','final_submission_date','start_date'];

这是一个字段,我想在字段中设置日期,从数据库中检索记录。

<input class="form-control" type="date" name="start_date" value="{{ $topic->start_date}}" id = "start_date" onkeyup = "Validate(this)" required min=<?php
                                    echo date('Y-m-d');
                                    ?> />
html5 laravel date laravel-5.5 mutators
1个回答
2
投票

使用format()设置格式

{{ $topic->start_date->format('Y-m-d')}}

在你的代码中

<input class="form-control" type="date" name="start_date" value="{{ $topic->start_date->format('Y-m-d)}}" id = "start_date" onkeyup = "Validate(this)" required min=<?php
                                echo date('Y-m-d');
                                ?> />

希望这可以帮助

© www.soinside.com 2019 - 2024. All rights reserved.