<body>
<table width="747" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="739" bgcolor="#008080"><script language=JavaScript>
today=new Date();
function initArray(){
this.length=initArray.arguments.length
for(var i=0;i<this.length;i++)
this[i+1]=initArray.arguments[i] }
var d=new initArray(
"星期日",
"星期一",
"星期二",
"星期三",
"星期四",
"星期五",
"星期六");
document.write(
"<font style='font-size: 9pt' face='Arial' color='#FFFFFF'> ",
today.getYear(),"年",
today.getMonth()+1,"月",
today.getDate(),"日",
d[today.getDay()+1],
"</b></font>" );
</script> <span id="clock" > </span> <!--定义一个时钟--> <script language="JavaScript"> //开始创建时钟!!
<!--jun() //执行“jun()”方法function jun(){ // 此处为方法"jun()"开始
//以下设定时钟的属性,获取系统的时钟。
var now=new Date()
var hours=now.getHours()
var minutes=now.getMinutes()
var seconds=now.getSeconds()
if (hours==0) hours=12 //判断小时的表示形式。
if (minutes<=9) minutes="0"+minutes //判定分钟:当个位数时,前面加0,反之不加。
if (seconds<=9) seconds="0"+seconds //判定秒钟:当个位数时,前面加0,反之不加。
myclock="<font style='font-size: 9pt' face='Arial' color='#FFFFFF' > "+hours+":"+minutes+":"+seconds+" </font>" //定义时间的输出形式。
clock.innerHTML=myclock
setTimeout("jun()",1000) //此处使方法“jun()”循环间隔1秒。
}
//--> </script></td>
</tr>
</table>
<table width="747" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="739" bgcolor="#008080"><script language=JavaScript>
today=new Date();
function initArray(){
this.length=initArray.arguments.length
for(var i=0;i<this.length;i++)
this[i+1]=initArray.arguments[i] }
var d=new initArray(
"星期日",
"星期一",
"星期二",
"星期三",
"星期四",
"星期五",
"星期六");
document.write(
"<font style='font-size: 9pt' face='Arial' color='#FFFFFF'> ",
today.getYear(),"年",
today.getMonth()+1,"月",
today.getDate(),"日",
d[today.getDay()+1],
"</b></font>" );
</script> <span id="clock" > </span> <!--定义一个时钟--> <script language="JavaScript"> //开始创建时钟!!
<!--jun() //执行“jun()”方法function jun(){ // 此处为方法"jun()"开始
//以下设定时钟的属性,获取系统的时钟。
var now=new Date()
var hours=now.getHours()
var minutes=now.getMinutes()
var seconds=now.getSeconds()
if (hours==0) hours=12 //判断小时的表示形式。
if (minutes<=9) minutes="0"+minutes //判定分钟:当个位数时,前面加0,反之不加。
if (seconds<=9) seconds="0"+seconds //判定秒钟:当个位数时,前面加0,反之不加。
myclock="<font style='font-size: 9pt' face='Arial' color='#FFFFFF' > "+hours+":"+minutes+":"+seconds+" </font>" //定义时间的输出形式。
clock.innerHTML=myclock
setTimeout("jun()",1000) //此处使方法“jun()”循环间隔1秒。
}
//--> </script></td>
</tr>
</table>
是具体几周第几天还需要加点程序
脚本说明:
第一步:把如下代码加入<body>区域中
<script language="JavaScript">
<!-- Hide
var timerID = null
var timerRunning = false
function MakeArray(size)
{
this.length = size;
for(var i = 1; i <= size; i++)
{
this[i] = "";
}
return this;
}
function stopclock (){
if(timerRunning)
clearTimeout(timerID);
timerRunning = false
}
function showtime () {
var now = new Date();
var year = now.getYear();
var month = now.getMonth() + 1;
var date = now.getDate();
var hours = now.getHours();
var minutes = now.getMinutes();
var seconds = now.getSeconds();
var day = now.getDay();
Day = new MakeArray(7);
Day[0]="星期天";
Day[1]="星期一";
Day[2]="星期二";
Day[3]="星期三";
Day[4]="星期四";
Day[5]="星期五";
Day[6]="星期六";
var timeValue = "";
timeValue += year + "年";
timeValue += ((month < 10) ? "0" : "") + month + "月";
timeValue += date + "日 ";
timeValue += (Day[day]) + " ";
timeValue += ((hours <= 12) ? hours : hours - 12);
timeValue += ((minutes < 10) ? ":0" : ":") + minutes;
timeValue += ((seconds < 10) ? ":0" : ":") + seconds;
timeValue += (hours < 12) ? "上午" : "下午";
document.jsfrm.face.value = timeValue;
timerID = setTimeout("showtime()",1000);
timerRunning = true
}
function startclock () {
stopclock();
showtime()
}
//--></script>
<form name='jsfrm'>
<input type=text name='face' size=34 value=''>
</form>第二步:把<body>中的内容改为:
<body bgcolor="#fef4d9" onLoad="startclock()">
function test(y,n) {
d = new Date((new Date(y,0,1)).getTime()+(n-1)*24*60*60*1000);
document.write(y+"年第"+n+"天是:"+d.toLocaleString().replace(/ .+/,'')+"星期"+(d.getDay()==0?7:d.getDay())+"<br>");
}
for(i=2000;i<2004;i++)
test(i,60);
</script>