被Json格式化后那可怜的时间

时间:2015-11-20 19:49:29   收藏:0   阅读:198

技术分享

  function renderTime(date) {
            var da = new Date(parseInt(date.replace("/Date(", "").replace(")/", "").split("+")[0]));
            Year = da.getFullYear(); //ie火狐下都可以
            Month = da.getMonth() + 1;
            Day = da.getDate();

            var CurrentDate = "";
            CurrentDate += Year + "-";
            if (Month >= 10) {
                CurrentDate += Month + "-";
            }
            else {
                CurrentDate += "0" + Month + "-";
            }
            if (Day >= 10) {
                CurrentDate += Day;
            }
            else {
                CurrentDate += "0" + Day;
            }
            return CurrentDate + " " + da.getHours() + ":" + da.getSeconds() + ":" + da.getMinutes();
        }
技术分享

原文:http://www.cnblogs.com/qh1688/p/4981423.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!