日期格式为
日期小于10的时候 占一位
比如 2019年9月1日
2015/9/1
function ChangeDateFormat(cellval) {
var date = new Date(parseInt(cellval.replace("/Date(", "").replace(")/", ""), 10));
var month = date.getMonth() + 1;
var currentDate = date.getDate();
return date.getFullYear() + "/" + month + "/" + currentDate;
}
这里只是个人记录而已
yyyy/mm/dd
日期小于10的时候 占两位。个人推荐使用下面这一种方式去生成。
比如 2019年9月1日
2015/09/01
function ChangeDateFormat(cellval) {
var date = new Date(parseInt(cellval.replace("/Date(", "").replace(")/", ""), 10));
var month = date.getMonth() + 1;
var currentDate = date.getDate();
if (month < 10) {
month="0"+month.toString();
}
if (currentDate < 10) {
currentDate = "0" + currentDate.toString();
}
return date.getFullYear() + "/" + month + "/" + currentDate;
}
原文:http://www.cnblogs.com/jixinyu12345/p/4888831.html