(1)服务器传到前台是时间戳
(2)把时间戳转换为"yyyy-MM-dd"型字符串
jsp: <input class="form-control" id="updateAt" type="date" value=""/>
js:
$(document).ready(function () {
Date.prototype.format = function (format) {
var o = {
"M+": this.getMonth() + 1,
"d+": this.getDate(),
"h+": this.getHours(),
"m+": this.getMinutes(),
"s+": this.getSeconds(),
"q+": Math.floor((this.getMonth() + 3) / 3),
"S": this.getMilliseconds()
};
if (/(y+)/.test(format)) {
format = format.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
}
for (var k in o) {
if (new RegExp("(" + k + ")").test(format)) {
format = format.replace(RegExp.$1, RegExp.$1.length == 1 ? o[k] : ("00" + o[k]).substr(("" + o[k]).length));
}
}
return format;
};
}
function show(id) {jQuery.ajax({
type: 'POST',
url: url,
cache: false,
data: {id: id},
success: function (data) {
$("#update_edoc").val(new Date(data.record.updateAt).format("yyyy-MM-dd"));},
error: function (jqXHR, textStatus, errorThrown) {
showInfo("操作失败,请重试");
}
});
}