<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
</body>
<script>
// 时间对象date
var _date = new Date();
// 时间对象获取到的是当前的时间.
console.log(_date) ;
// 我们可以通过在date中传入数字来设置时间.
// 获取年 getFullYears()
var year = _date.getFullYear();
console.log(year)
//获取月 getMonth() 该方法获取到的月份0-11;
var month = _date.getMonth();
console.log(month)
// 获取天数 getDate()
var day = _date.getDate();
console.log(day)
// 获取星期几 getDay()
var week =_date.getDay();
console.log(week);
// 获取小时 getHour()
var hour =_date.getHours();
console.log(hour);
// 获取分钟 getMinutes()
var minutes =_date.getMinutes();
console.log(minutes);
// 获取秒钟 getSeconds()
var sec =_date.getSeconds();
console.log(sec);
// 时间戳 getTime() 1970年0点0分0秒到现在的秒数.
var _time =_date.getTime();
console.log(_time);
</script>
</html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
</body>
<script>
// 时间对象date
var _date = new Date();
// 时间对象获取到的是当前的时间.
console.log(_date) ;
// 我们可以通过在date中传入数字来设置时间.
// 获取年 getFullYears()
var year = _date.getFullYear();
console.log(year)
//获取月 getMonth() 该方法获取到的月份0-11;
var month = _date.getMonth();
console.log(month)
// 获取天数 getDate()
var day = _date.getDate();
console.log(day)
// 获取星期几 getDay()
var week =_date.getDay();
console.log(week);
// 获取小时 getHour()
var hour =_date.getHours();
console.log(hour);
// 获取分钟 getMinutes()
var minutes =_date.getMinutes();
console.log(minutes);
// 获取秒钟 getSeconds()
var sec =_date.getSeconds();
console.log(sec);
// 时间戳 getTime() 1970年0点0分0秒到现在的秒数.
var _time =_date.getTime();
console.log(_time);
</script>
</html>