<script>
var date= new Date();
/* 年月日 */
console.log(date)
var year = date.getFullYear();
console.log(year)
/* 月份从0开始 */
var month = date.getMonth()+1;
console.log(month)
var data = date.getDate();
console.log(data)
</script>
获取当前的时间
<script>
var d = new Date();
var hours = d.getHours();
var minutes = d.getMinutes();
var seconds = d.getSeconds();
console.log(hours)
console.log(minutes)
console.log(seconds)
</script>