利用JS获取当前系统时间

Original 2019-04-27 18:08:12 286
abstract:利用js的date函数可以获取当前电脑时间,并可以分不同的时间种类获取单个时间值<!DOCTYPE html><html><head>    <meta charset="UTF-8">    <title>Date日期操作</title></head>&

利用js的date函数可以获取当前电脑时间,并可以分不同的时间种类获取单个时间值


<!DOCTYPE html>
<html>
<head>
   <meta charset="UTF-8">
   <title>Date日期操作</title>
</head>
<body>
<script>
   let time = new Date();
   document.write(time+'<br>')

   Year = time.getFullYear()//年
   Month = time.getMonth()+1//月0代表1月
   Day = time.getDate()//日

   Hours = time.getHours()//时
   Minutes = time.getMinutes()//分
   Seconds = time.getSeconds()//秒

   document.write('现在的时间是'+ Year+'年'+Month+'月'+Day+'日 '+Hours+':'+Minutes+':'+Seconds)


</script>

</body>
</html>

Correcting teacher:天蓬老师Correction time:2019-04-28 09:10:43
Teacher's summary:Year = time.getFullYear()//年 Month = time.getMonth()+1//月0代表1月 Day = time.getDate()//日 Hours = time.getHours()//时 Minutes = time.getMinutes()//分 Seconds = time.getSeconds()//秒 你这样写会创建

Release Notes

Popular Entries