时间戳转换为"yyyy-MM-dd hh:mm:ss"格式(24小时)

//时间戳格式化
                                        value="/Date(1451466990767)/";
				        Otime = value.replace("/Date(", "").replace(")/", "").substr(0, 10);
                        //此时Otime=“1451466990”
				        function formatDate(now) {
				            var year = now.getFullYear();
				            var month = now.getMonth() + 1;
				            if (month < 9) {
				                month = "0" + month;
				            }
				            var date = now.getDate();
				            if (date < 9) {
				                date = "0" + date;
				            }
				            var hour = now.getHours();
				            if (hour < 9) {
				                hour = "0" + hour;
				            }
				            var minute = now.getMinutes();
				            if (minute < 9) {
				                minute = "0" + minute;
				            }
				            var second = now.getSeconds();
				            if (second < 9) {
				                second = "0" + second;
				            }
				            return year + "-" + month + "-" + date + "   " + hour + ":" + minute + ":" + second;
				        }
				        var d = new Date(parseInt(Otime) * 1000);
				        alert(formatDate(d));
                                        //弹出结果为2015-12-30 17:16:30

  

原文地址:https://www.cnblogs.com/kelly007/p/5129300.html