用JS在你的网页上显示当前时间

  1. <font color="red"><b>
  2. <script language="JavaScript">
  3. <!--
  4. tmpDate = new Date();
  5. date = tmpDate.getDate();
  6. month= tmpDate.getMonth() + 1 ;
  7. myyear= tmpDate.getYear();
  8. year=(myyear > 200) ? myyear : 1900 + myyear;
  9.  
  10. document.write(year);
  11. document.write("年");
  12. document.write(month);
  13. document.write("月");
  14. document.write(date);
  15. document.write("日 ");
  16.  
  17. myArray=new Array(6);
  18. myArray[0]="星期日"
  19. myArray[1]="星期一"
  20. myArray[2]="星期二"
  21. myArray[3]="星期三"
  22. myArray[4]="星期四"
  23. myArray[5]="星期五"
  24. myArray[6]="星期六"
  25. weekday=tmpDate.getDay();
  26. if (weekday==0 | weekday==6)
  27. {
  28. document.write(myArray[weekday])
  29. }
  30. else
  31. {document.write(myArray[weekday])
  32. };
  33.  
  34. hours = tmpDate.getHours();
  35. minutes = tmpDate.getMinutes();
  36. seconds = tmpDate.getSeconds();
  37. times = "<font color=orange>" + ((hours >24) ? hours -12 :hours); times += ((minutes < 10) ? "<blink>:</blink>0" : "<blink>:</blink>") + minutes+"</font>";
  38. times += (hours >= 12) ? "<b>PM</b>" : "<b>AM</b>";
  39. document.write(times);
  40. // -->
  41. </script>
  42. </b></font>

相似日志:

发表评论