![](/img/trans.png)
[英]Force a leading zero to show on page for input type="text" for time format hh:mm:ss
[英]Show HH:MM in input type time
我正在嘗試使用帶有以下代碼的html輸入字段:
<td><input style="width: 80px" type="time" placeholder="HH:MM" required="" data-bind="value: FirstManifest"></td>
正確地填充了包含FirstManifest屬性(DateTime?)的后端C#對象,但是當我將其綁定到爆震視圖模型時,模型FirstManifest中的屬性看起來像這樣
"/Date(1464748440000)/"
如何轉換此格式,以便我的輸入僅顯示日期時間格式HH:MM?
它將轉換為毫秒。請嘗試將其轉換回原樣。
var oldDate= "/Date(1464748440000)/"; var newDate = new Date(parseInt(oldDate.substr(6))); document.write(newDate);
我相信這就是.NET將其序列化DateTime的方式。 您首先需要將其轉換為JavaScript Date,然后獲取time元素,例如
var manifest
= new Date(parseInt("/Date(1464748440000)/".replace("/Date(", "").replace(")/",""), 10));
this.FirstManifest = ko.computed(function() {
return manifest.toLocaleTimeString();
}, this);
您還需要計算值的write
部分從輸入轉換回日期,以便持久存儲到服務器。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.