//對日期中部分小於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);