用JS将json日期格式化成正常日期

   function ChangeDateFormat(cellval) {

            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 @ 2016-07-01 20:39  576  阅读(497)  评论(0编辑  收藏  举报