【发布时间】:2019-07-19 04:01:54
【问题描述】:
DD-MM-YYYY 中的字符串在转换为日期并传递到 html.editor 时不显示正确的值。
@Html.Editor("StartDate", new { htmlAttributes = new { @class = "form-control", @type = "date", @placeholder = " Start Date", @required = "", @id = "txtStrDate" } })
var myDate = document.querySelector(".update_ano #txtStrDate");
var Displaydate = convertDateToRequiredFormat(strdate); // Converts date to DD-MM-YYYY
var dateFormatted = new Date(Displaydate.replace(/(\d{2})-(\d{2})-(\d{4})/, "$2/$1/$3"));
console.log(dateFormatted)//Shows the correct date format
myDate.value = dateFormatted;
console.log(myDate.value);// Shows empty Console
【问题讨论】:
标签: javascript c# razor