如果我在MVC中使用EditFor,我的日期時間字段顯示不是格式化的日期時間,如果我使用舊的學校html,我的字段不會收到錯誤類。MVC輸入日期時間
<div class="editor-field">
<input type="text" name="EstimateTime" id="EstimateTime" value="<%: (Model != null) ? Model.EstimateTime.ToString("dd/MM/yyyy hh:mm:ss tt") : "" %>" />
<%: Html.TextBoxFor(model => model.EstimateTime, new { @value = (Model != null) ? Model.EstimateTime.ToString("dd/MM/yyyy hh:mm:ss tt") : "" })%>
<%: Html.ValidationMessageFor(model => model.EstimateTime) %>
</div>
結果HTML:看的價值之間的差額:
<div class="editor-field">
<input type="text" name="EstimateTime" id="EstimateTime" value="31/10/2013 01:54:42 PM" class="hasDatepicker">
<input id="EstimateTime" name="EstimateTime" type="text" value="10/31/2013 1:54:42 PM" class="input-validation-error text-box single-line">
<span class="field-validation-error">Isn't a date/time valid</span>
</div>
什麼是解決它的最佳實踐?
它交換了一個月的一天。有什麼大不了的? –
問題是,如果我使用Model.EstimateTime.ToString(「dd/MM/yyyy hh:mm:ss tt」)日期顯示爲格式MM/dd/..... – AFetter