日期時間顯示
將下列程式碼複製至<body>程式碼</body>區內。
<script language="JavaScript"> <!-- Hide this script from old browsers -- /* This script came from the 24 hour JavaScripts Site located at http://www.javascripts.com. It is brought to you by Eric Jarvies, Lewis Sellers, Giuseppe Lombardo, Kurt Anderson, and David Medinets. */ Stamp = new Date(); document.write('<font size="2" face="Arial,Geneva,Sans Serif"><B>' + (Stamp.getMonth() + 1) +"/"+Stamp.getDate()+ "/"+Stamp.getYear() + '</B></font><BR>'); var Hours; var Mins; var Time; Hours = Stamp.getHours(); if (Hours >= 12) { Time = " P.M."; } else { Time = " A.M."; } if (Hours > 12) { Hours -= 12; } if (Hours == 0) { Hours = 12; } Mins = Stamp.getMinutes(); if (Mins < 10) { Mins = "0" + Mins; } document.write('<font size="2" face="Arial,Geneva,Sans Serif"><B>' + Hours + ":" + Mins + Time + '</B></font>'); // -- End Hiding Here --> </script> |