function format(date){ var week=['日','一','二','三','四','五','六',]; var y=date.getFullYear()+"年"; var m=date.getMonth()+1+"月"; var d=date.getDate()+"日"; var w=" 星期"+week[date.getDay()]; //12;00;00.000 var h=date.getHours(); var am=h>=12?" 下午":" 上午"; h=h>12?h-12:h;//24 to 12 h=h<10?"0"+h:""+h; var mi=date.getMinutes(); mi=mi<10?"0"+mi:""+mi; var s=date.getSeconds(); s=s<10?"0"+s:""+s; return y+m+d+w+am+h+":"+mi+":"+s; } document.write(format(new Date()));