亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

js中關(guān)于獲取日期的一些函數(shù)

Original 2019-01-06 16:37:00 281
abstract:<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Date(日期操作方法)</title> </head> <body> <script> // 日期對象是用以處理日期和時
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Date(日期操作方法)</title>
</head>
<body>
<script>
// 日期對象是用以處理日期和時間的
// 獲取當前時間
var myDay = new Date();
document.write('當前時間是:' + myDay + '<br/>');
// 獲取年份 getFullYear()
document.write('今年是:' + myDay.getFullYear() + '年<br/>');
// 獲取月份 getMonth() 從0開始,0代表1月,11代表的是12月
document.write(myDay.getMonth() + 1 + '月<br/>');
var month = new Array(12);
month[0] = '一月';
month[1] = '二月';
month[2] = '三月';
month[3] = '四月';
month[4] = '五月';
month[5] = '六月';
month[6] = '七月';
month[7] = '八月';
month[8] = '九月';
month[9] = '十月';
month[10] = '十一月';
month[11] = '十二月';
document.write("這個月是"+month[myDay.getMonth()] +'<br/>');
// 獲取星期 getDay() 0代表的是周日,6代表的是周六 (返回值是0-6之間的一個整數(shù))
var week = new Array(7);
week[0] = '星期日';
week[1] = '星期一';
week[2] = '星期二';
week[3] = '星期三';
week[4] = '星期四';
week[5] = '星期五';
week[6] = '星期六';
document.write("今天是" + week[myDay.getDay()] + '<br/>');
// 獲取日期 getDate() 返回值是0~31之間的一個整數(shù)
document.write("今天是這個月的第" + myDay.getDate()+'天<br/>');
// 獲取小時 getHours() (返回值是0~23之間的一個整數(shù))
document.write("現(xiàn)在是" + myDay.getHours()+'時');
// 獲取分鐘 getMinutes()(返回值是0~59之間的一個整數(shù))
document.write(myDay.getMinutes()+'分');
// 獲取秒數(shù) getSeconds()(返回值是0~59之間的一個整數(shù))
document.write(myDay.getSeconds()+'秒');

</script>
</body>
</html>

微信截圖_20190106163553.png

Correcting teacher:滅絕師太Correction time:2019-01-06 16:44:39
Teacher's summary:除了測試上課代碼,還可以帶點案例奧!日期函數(shù)相對比較簡單,要好好掌握

Release Notes

Popular Entries