js转换日期格式

function changeDateFormat(cellval) {
if (cellval != null) {
var date = new Date(parseInt(cellval.replace("/Date(", "").replace(")/", ""), 10));
var month = date.getMonth() + 1 < 10 ? "0" + (date.getMonth() + 1) : date.getMonth() + 1;
var currentDate = date.getDate() < 10 ? "0" + date.getDate() : date.getDate();
return date.getFullYear() + "-" + month + "-" + currentDate;
}
}

posted @ 2019-02-22 16:28  海潮之声梦菲儿  阅读(515)  评论(0)    收藏  举报