使用 getDay() 来显示星期,而不仅仅是数字

  1. <html>
  2. <body>
  3.  
  4. <script type="text/javascript">
  5.  
  6. var d=new Date()
  7. var weekday=new Array(7)
  8. weekday[0]="星期日"
  9. weekday[1]="星期一"
  10. weekday[2]="星期二"
  11. weekday[3]="星期三"
  12. weekday[4]="星期四"
  13. weekday[5]="星期五"
  14. weekday[6]="星期六"
  15.  
  16. document.write("今天是" + weekday[d.getDay()])
  17.  
  18. </script>
  19.  
  20. </body>
  21. </html>