<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<script>
/*内置对象API
*/
//创建日期对象
var myDate = new Date();
console.log(myDate);
//1.转换格式
console.log(myDate.toLocaleString());//2019/9/25 上午9:02:33
console.log(myDate.toLocaleDateString());//2019/9/25
console.log(myDate.toLocaleTimeString());//上午9:02:33
//2.获取年月日时分秒
console.log(myDate.getFullYear());//年 2019
//月份获取的是下标 1 - 12 月 对应下标 0 - 11
console.log(myDate.getMonth());//月 8下标 9月
console.log(myDate.getDate());//日 25
//星期获取的是下标 星期天 - 星期六 对应下标 0 - 6
console.log(myDate.getDay());//星期 3
console.log(myDate.getHours());//时 9
console.log(myDate.getMinutes());//分 7
console.log(myDate.getSeconds());//秒i
console.log(myDate.getMilliseconds());//毫秒 ms
//3.自定义时间
//3.1 参数: 年月日时分秒
var date1 = new Date(2018,11,20,8,30,30);
console.log(date1);
//3.2 参数; YYYY-MM-DD HH:mm:ss
var date2 = new Date('2019-10-01 10:30:30');
console.log(date2);
</script>
</body>
</html>