0

我无法弄清楚将我的时间显示到时间文本框中的秘密格式字符串。时间以这种格式“10:30 AM”存储在数据库中,DeliveryTime 在数据库中定义为字符串。我尝试了与下面类似的各种版本,但均无济于事。请帮忙。

<input type="time" id="DeliveryTime" name="DeliveryTime" class="form-control" value="@Model.DeliveryTime.ToString("hh:mm tt")">
4

1 回答 1

0

查看数据库中值的格式(上午 10:30)和您尝试使用的格式:hh:mm tt,它们是相同的..所以您需要做的就是直接显示它:

<input type="time" id="DeliveryTime" name="DeliveryTime" class="form-control" value="@Model.DeliveryTime">

或者我在这里错过了什么?

于 2013-08-14T02:08:56.870 回答