<script>
function getDate(date) {
//var date=new Date();
var year=date.getFullYear();
var month=date.getMonth()+1; //返回月份,从0开始,比如现在是10月份,但是结果会显示9。所以一般我们获取真实的月份会是这样:getMonth()+1
var day=date.getDate();
var hour=date.getHours();
var minutes=date.getMinutes();
var seconds=date.getSeconds();
month=month>9?month:"0"+month;
day=day>9?day:"0"+day;
hour=hour>9?hour:"0"+hour;
minutes=minutes>9?minutes:"0"+minutes;
seconds=seconds>9?seconds:"0"+seconds;
return (year+"年"+ month+"月"+ day+"日"+ hour+":"+ minutes+":"+ seconds);
}
console.log(getDate(new Date()));
</script>