fengchuanyu 18 小時之前
父節點
當前提交
4f7f917055
共有 1 個文件被更改,包括 38 次插入0 次删除
  1. 38 0
      3_JavaScript/25_时间对象.html

+ 38 - 0
3_JavaScript/25_时间对象.html

@@ -0,0 +1,38 @@
+<!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>
+        // 时间对象 new Date();
+        // 时间对象可以用来表示时间
+        var date = new Date();
+
+        // 获取时间对象的年
+        console.log(date.getFullYear());
+        // 获取时间对象的月 月份从0开始
+        console.log((date.getMonth()+1));
+        // 获取时间对象的天
+        console.log(date.getDate());
+
+        // 获取时间对象的小时
+        console.log(date.getHours());
+        // 获取时间对象的分钟
+        console.log(date.getMinutes());
+        // 获取时间对象的秒
+        console.log(date.getSeconds());
+
+        // 获取星期 星期天为 0, 星期一为 1, 以此类推
+        console.log(date.getDay());
+
+        
+
+        // Number对象
+        var a = 10;
+        console.log(a.toString());
+    </script>
+</body>
+</html>