abstract:利用js的date函數(shù)可以獲取當(dāng)前電腦時(shí)間,并可以分不同的時(shí)間種類獲取單個(gè)時(shí)間值<!DOCTYPE html><html><head> <meta charset="UTF-8"> <title>Date日期操作</title></head>&
利用js的date函數(shù)可以獲取當(dāng)前電腦時(shí)間,并可以分不同的時(shí)間種類獲取單個(gè)時(shí)間值
<!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()//時(shí)
Minutes = time.getMinutes()//分
Seconds = time.getSeconds()//秒
document.write('現(xiàn)在的時(shí)間是'+ 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()//時(shí)
Minutes = time.getMinutes()//分
Seconds = time.getSeconds()//秒
你這樣寫會(huì)創(chuàng)建