function ConvertJSONDateToJSDateObject(jsondate) { var date = new Date(parseInt(jsondate.replace("/Date(", "").replace(")/", ""), 10)); return date; } 做替换使用 |
只要把DateTime值传递给ConvertJSONDateToJSDateObject就可以返回Date。通过js调用。
如果想返回yyyy-MM-dd HH:mm:SS格式
function getDate(date) {
var year = date.getFullYear();
var month = date.getMonth() + 1;
var day = date.getDate();
return year + "-" + month + "-" + day ;
} function getDateTime(date) {
var year = date.getFullYear();
var month = date.getMonth() + 1;
var day = date.getDate();
var hh = date.getHours();
var mm = date.getMinutes();
var ss = date.getSeconds();
return year + "-" + month + "-" + day + " " + hh + ":" + mm + ":" + ss;
} |