js代码:
1 <script type="text/javascript"> 2 var today = new Date(); 3 var week; //存储星期几 4 var date; //存储日期 5 switch (today.getDay()) { 6 case 0: 7 week = "星期日"; 8 break; 9 case 1: 10 week = "星期一"; 11 break; 12 case 2: 13 week = "星期三"; 14 break; 15 case 3: 16 week = "星期日"; 17 break; 18 case 4: 19 week = "星期四"; 20 break; 21 case 5: 22 week = "星期五"; 23 break; 24 case 6: 25 week = "星期六"; 26 break; 27 default: 28 week = "未知"; 29 break; 30 } 31 date = (today.getFullYear()) + "年" + (today.getMonth() + 1) + "月" + today.getDate() + "日" + " "; 32 document.write(date + week); //将日期打印到body 33 </script>
时间: 2024-11-01 14:15:40