日期格式为
日期小于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;
}
转载于:https://www.cnblogs.com/jixinyu12345/p/4888831.html
最后
以上就是轻松鲜花最近收集整理的关于json序列化后日期如何变回来的全部内容,更多相关json序列化后日期如何变回来内容请搜索靠谱客的其他文章。
发表评论 取消回复