abstract:<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width,&
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>Document</title> <script type="text/javascript"> var myday = new Date(); // 由于國(guó)外的計(jì)時(shí)是從0開(kāi)始的所以系統(tǒng)的11月是代表是12月! //"."的意思是將兩個(gè)函數(shù)進(jìn)行連接 //myday 是獲取當(dāng)前的系統(tǒng)時(shí)間 //month 是構(gòu)造一個(gè)數(shù)組,解決國(guó)外時(shí)間規(guī)則與國(guó)內(nèi)時(shí)間相差一個(gè)小時(shí)的問(wèn)題 // document.write( myday);//獲取當(dāng)前的時(shí)間 // document.write(myday.getFullYear()+"年");//獲取年份一定要先調(diào)用了new Date獲取到當(dāng)前時(shí)間才能獲取到年份 // document.write(myday.getMonth()+"月"); 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("這個(gè)月是"+month[myday.getMonth()]);//輸出數(shù)組中判斷當(dāng)前的月份,如不使用數(shù)組來(lái)獲取當(dāng)前的月份則無(wú)輸出的月份比實(shí)際會(huì)少一個(gè)月 document.write("<br>"); document.write("今天是星期"+myday.getDay());//getDay 獲取當(dāng)前的星期 document.write("<br>"); document.write(myday.getDate());//getDate 獲取當(dāng)前的日期 document.write("<br>"); document.write(myday.getHours());//getHours 獲取到當(dāng)前的時(shí)鐘 document.write("<br>"); document.write(myday.getMinutes());//getMinutes 獲取當(dāng)前的分鐘 document.write("<br>"); document.write(myday.getSeconds());//getSeconds 獲取當(dāng)前秒鐘 </script> </head> <body> </body> </html>
Correcting teacher:查無(wú)此人Correction time:2018-11-25 09:37:42
Teacher's summary:嗯,做的不錯(cuò)。日期時(shí)間,是個(gè)麻煩的東西,要多練習(xí),才能記住。加油。