json 时间日期转换

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了json 时间日期转换相关的知识,希望对你有一定的参考价值。

 function jsonDateFormat(jsonDate) {
        try {
            var date = new Date(parseInt(jsonDate.replace("/Date(", "").replace(")/", ""), 10));
            var month = date.getMonth() + 1 < 10 ? "0" + (date.getMonth() + 1) : date.getMonth() + 1;
            var day = date.getDate() < 10 ? "0" + date.getDate() : date.getDate();
            var hours = date.getHours();
            var minutes = date.getMinutes();
            var seconds = date.getSeconds();
            var milliseconds = date.getMilliseconds();
            return date.getFullYear() + "-" + month + "-" + day + " " + hours + ":" + minutes + ":" + seconds + "." + milliseconds;
        } catch (ex) {
            return "";
        }
    }

 

以上是关于json 时间日期转换的主要内容,如果未能解决你的问题,请参考以下文章