js时间显示设置

//对日期中部分小于10的数字前边添加0
function zero(s){
    return s < 10 ? '0' + s: s;
}

var date=new Date(),
       year = date.getFullYear(),
       month = date.getMonth()+1,
       day = date.getDate(),
       hour = date.getHours(),
       minute = date.getMinutes(),
       second = date.getSeconds();
var newTime=year+'年'+zero(month)+'月'+zero(day)+'日 '+zero(hour)+':'+zero(minute)+':'+zero(second);
原文地址:https://www.cnblogs.com/dongxiaolei/p/5856269.html