码迷,mamicode.com
首页 > Web开发 > 详细

json 时间日期转换

时间:2017-05-16 13:10:30      阅读:309      评论:0      收藏:0      [点我收藏+]

标签:blog   format   color   gets   get   日期   min   turn   ret   

 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 时间日期转换

标签:blog   format   color   gets   get   日期   min   turn   ret   

原文地址:http://www.cnblogs.com/wc918/p/6860591.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!