星期六 13:48:56)
<SCRIPT language=JavaScript>
<!--
//以下是年月日星期顯示
tmpDate=new Date();date=tmpDate.getDate();month=tmpDate.getMonth()+1;year=tmpDate.getYear();document.write(year);document.write(".");document.write(month);document.write(".");document.write(date);document.write(" ");myArray=new Array(6);myArray[0]="星期日 "
myArray[1]="星期壹 "
myArray[2]="星期二 "
myArray[3]="星期三 "
myArray[4]="星期四 "
myArray[5]="星期五 "
myArray[6]="星期六 "
weekday=tmpDate.getDay();if(weekday==0|weekday==6)
{document.write(myArray[weekday])
}else
{document.write(myArray[weekday])
};
//-->
</SCRIPT>
<SCRIPT language=Javascript1.2>
<!--
//以下是時間顯示
var tags_before_clock = ""
var tags_after_clock = ""
if(navigator.appName == "Netscape") {
document.write('<layer id="clock"></layer>');
}
if (navigator.appVersion.indexOf("MSIE") != -1){
document.write('<span id="clock"></span>');
}
function showclock()
{
var date = new Date();
var hour = date.getHours();
var min = date.getMinutes();
var sec = date.getSeconds();
var col = ":";
var spc = " ";
var apm;
if ( hour >12 )
{
apm="P.M.";
hour=hour-12;
}
else
{
apm="A.M.";
}
if (hour == 0) hour=12;
if (min<=9) min="0"+min;
if (sec<=9) sec="0"+sec;
if(navigator.appName == "Netscape")
{
document.clock.document.write(tags_before_clock
+hour+col+min+col+sec+spc+tags_after_clock);
document.clock.document.close();
}
if (navigator.appVersion.indexOf("MSIE") != -1)
{
clock.innerHTML = tags_before_clock+hour
+col+min+col+sec;
}
}
setInterval("showclock()",1000);
//-->
</SCRIPT>
2.年月日星期時間代碼形式( 現在是2009年2月14日13時49分58秒)
<script language=Javascript>
var now=new Date()
document.write(" 現在是"+now.getYear()+"年"+(now.getMonth()+1)+"月"+now.getDate()+" 日"+now.getHours()+"時"+now.getMinutes()+"分"+now.getSeconds()+"秒")
</script>