javascript中将json日期格式转化成标准日期格式

来源:互联网 发布:cf数据异常封号1小时 编辑:程序博客网 时间:2024/05/17 22:01
//转化json数据的日期        function ChangeDateFormat(jsondate) {            jsondate = jsondate.replace("/Date(", "").replace(")/", "");                        if (jsondate.indexOf("+") > 0) {                jsondate = jsondate.substring(0, jsondate.indexOf("+"));            } else if (jsondate.indexOf("-") > 0) {                jsondate = jsondate.substring(0, jsondate.indexOf("-"));            }            //alert(jsondate);            var date = new Date(parseInt(jsondate, 10));            //alert(date.getHours());            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 + " " + date.getHours() + ":" + date.getMinutes() + ":" + date.getSeconds();        }


原创粉丝点击