显示时间及倒数日期
分类:电脑知识 发表于:2008-11-18 11:11:43 评论(0)
<div id="time" style="Z-INDEX: 99; LEFT: 150px; WIDTH: 300px; POSITION: absolute; TOP: 30px; HEIGHT: 20px;">time</div>
<script language="javascript">
function time1(){
now=new Date();
n = now.getYear()+"年";//得到年份
y = now.getMonth()+1;//得到月份
r = now.getDate();//得到天
h = now.getHours(); //得到小时
m = now.getMinutes(); //得到分钟
s = now.getSeconds(); //得到秒
x = now.getDay(); //得到星期
if(x == 0) weekday=" 星期日 ";
else if(x == 1) weekday=" 星期一 ";
else if(x == 2) weekday=" 星期二 ";
else if(x == 3) weekday=" 星期三 ";
else if(x == 4) weekday=" 星期四 ";
else if(x == 5) weekday=" 星期五 ";
else if(x == 6) weekday=" 星期六 ";
if(y < 10) y="0"+y;
if(r < 10) r="0"+r;
if(h < 10) h="0"+h;
if(m < 10) m="0"+m;
if(s < 10) s="0"+s;
document.all["time"].innerHTML="现在时间:"+n+y+"月"+r+"日"+weekday+" "+h+":"+m+":"+s;
}
setInterval('time1()',100);
</script>
<DIV class=style20
style="Z-INDEX: 99; LEFT: 150px; WIDTH: 300px; POSITION: absolute; TOP: 50px; HEIGHT: 16px;">
<SCRIPT language=JavaScript>
var urodz= new Date("12/25/2008");
var s="圣诞节";
var now = new Date();
var ile = urodz.getTime() - now.getTime();
var dni = Math.floor(ile / (1000 * 60 * 60 * 24))+1;
if (dni > 2)
document.write("离"+s+"还有"+dni +"天")
else if (dni == 2)
document.write("后天就是"+s+"啦!")
else if (dni == 1)
document.write("明天就是"+s+"啦!")
else if (dni == 0)
document.write(""+s+"快乐!")
else
document.write(""+s+"好象已经过了哦!");
</SCRIPT>
</DIV>