Date日期对象的运用

Original 2018-11-06 12:05:43 164
abstract:<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Document</title> </head> <body> <script type="text/javasc
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>


<script type="text/javascript">
var mydate = new Date();
document.write(mydate.getFullYear()+"年")
// document.write(mydate.getMonth());
var month = new Array(12)
month[0] = "1月"
month[1] = "2月"
month[2] = "3月"
month[3] = "4月"
month[4] = "5月"
month[5] = "6月"
month[6] = "7月"
month[7] = "8月"
month[8] = "9月"
month[9] = "10月"
month[10] = "11月"
month[11] = "12月"
document.write(month[mydate.getMonth()])
document.write(mydate.getDate()+'日');
var monthDay = new Array(7)
monthDay[1] = "星期一"
monthDay[2] = "星期二"
monthDay[3] = "星期三"
monthDay[4] = "星期四"
monthDay[5] = "星期五"
monthDay[6] = "星期六"
monthDay[7] = "星期日"
document.write(monthDay[mydate.getDay()]);
document.write(mydate.getHours()+'时');
document.write(mydate.getMinutes()+'分');
document.write(mydate.getSeconds()+'秒');



</script>

</body>
</html>

很有意思的对象调用,运用场景应该一般在论坛等交流场景吧

Correcting teacher:韦小宝Correction time:2018-11-06 13:45:37
Teacher's summary:作业写的很完整!也很不错!下次记得加点自己的总结在里面!以后当做笔记来回顾!日期对象使用的场景还是蛮多的哦!

Release Notes

Popular Entries