自动补零
(function() {
//创建补0函数
function p(s) {
return s < 10 ? '0' + s: s;
}
//创建、格式化时间函数
var younger_time = function(time) {
var time = new Date(time);
var year = time.getFullYear();
var month = time.getMonth() + 1;
var day = time.getDate();
//格式化时间
var str = year + '-' + p(month) + '-' + p(day);
//写入时间格式为 xxxx-xx-xx
document.getElementById("div_ID").innerHTML = str;
}
//服务器时间(毫秒为单位)
younger_time(ServerTime * 1000);
})()