日期对象案例

Original 2019-04-27 15:03:17 131
abstract:通过new Date()将当前时间信息赋值给变量,然后通过各种get...方法取得具体时间日期<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewpo

通过new Date()将当前时间信息赋值给变量,然后通过各种get...方法取得具体时间日期

<!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>
var today = new Date();
console.log(today.getFullYear() + '年');
var month = ['一月','二月','三月','四月','五月','六月','七月','八月','九月','十月','十一月','十二月'];
console.log(month[today.getMonth()]);
console.log(today.getDay()+'号');
console.log(today.getHours()+'点');
console.log(today.getMinutes() + '分');
console.log(today.getSeconds() + '秒');
</script>
</body>
</html>


Correcting teacher:查无此人Correction time:2019-04-27 17:35:58
Teacher's summary:完成的不错。js的时间一般是在日期时间选择框。继续加油。

Release Notes

Popular Entries