42 lines
1.0 KiB
HTML
42 lines
1.0 KiB
HTML
<!DOCTYPE html>
|
||
<html lang="en">
|
||
<head>
|
||
<meta charset="UTF-8">
|
||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||
<title>Document</title>
|
||
</head>
|
||
<body>
|
||
|
||
<script>
|
||
|
||
//00-创建当前日期
|
||
let newDate =new Date();
|
||
console.log(newDate);
|
||
|
||
|
||
//01-创建一个自定义日期
|
||
let customDate = new Date("2022-02-01 00:00:00");
|
||
console.log( customDate);
|
||
|
||
//02-获取日期对象中的属性
|
||
console.log( newDate.getFullYear()); //年
|
||
console.log( newDate.getMonth()+1); //月 (月份从0开始的)
|
||
console.log( newDate.getDate()); //日
|
||
console.log( newDate.getHours()); //时
|
||
console.log( newDate.getMinutes()); //分
|
||
console.log( newDate.getSeconds()); //秒
|
||
console.log( newDate.getMilliseconds());//毫秒
|
||
|
||
//特殊
|
||
//星期
|
||
console.log(newDate.getDay()); // 0星期天
|
||
|
||
console.log(newDate.getTime()); //时间戳 以毫秒为单位
|
||
|
||
|
||
|
||
</script>
|
||
|
||
|
||
</body>
|
||
</html> |