很实用,我们来看下代码:
<html>
head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<title>兼容FireFox的当前时间的JS脚本</title>
</head>
<body>
<DIV id=time>当前时间
<SCRIPT>document.getElementById('time').innerHTML=new Date().toLocaleString()+' 星期'+'日一二三四五六'.charAt(new Date().getDay());setInterval("document.getElementById('time').innerHTML=new Date().toLocaleString()+' 星期'+'日一二三四五六'.charAt(new Date().getDay());",1000);</SCRIPT>
</DIV>
</body>
</html>
////////////////////////////////******************** 2 ***************************////////////////////////////////////////////////////////////
<script language="JavaScript" type="text/javascript">
<!--
calendar = new Date(); //得到当前日期
day = calendar.getDay(); //当前多数号
month = calendar.getMonth(); //当前月份
date = calendar.getDate(); //当前星期
year = calendar.getYear(); //年份
hh=calendar.getHours(); //得到小时
mm=calendar.getMinutes();//得到分钟
ss=calendar.getSeconds();//得到秒数
if (year< 100) year = 1900 + year;
cent = parseInt(year/100);
g = year % 19;
k = parseInt((cent - 17)/25);
i = (cent - parseInt(cent/4) - parseInt((cent - k)/3) + 19*g + 15) % 30;
i = i - parseInt(i/28)*(1 - parseInt(i/28)*parseInt(29/(i+1))*parseInt((21-g)/11));
j = (year + parseInt(year/4) + i + 2 - cent + parseInt(cent/4)) % 7;
l = i - j;
emonth = 3 + parseInt((l + 40)/44);
edate = l + 28 - 31*parseInt((emonth/4));
emonth--;
var dayname = new Array ("星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六");
var monthname =
new Array ("1月","2月","3月","4月","5月","6月","7月","8月","9月","10月","11月","12月" );
document.write("今天是:");
document.write(year +"年");
document.write(monthname[month]);
document.write(date + "日"+" ");
document.write(dayname[day]+" ");
document.write("农历庚寅年 [虎年]");
//-->
</script>