一、实时走动的数字时钟 如:下午14:15:00
第一步:在<body></body>区域加入以下代码
XML/HTML代码
<script>
function tick(){
var hours, minutes, seconds,xfile;
var intHours, intMinutes,intSeconds;
vartoday;
today = newDate();
intHours =today.getHours();
intMinutes =today.getMinutes();
intSeconds =today.getSeconds();
if (intHours == 0){
hours ="12:";
xfile ="午夜";
} else if (intHours < 12){
hours =intHours+":";
xfile ="上午";
} else if (intHours == 12){
hours ="12:";
xfile ="正午";
} else{
intHoursintHours = intHours -12
hours = intHours +":";
xfile ="下午";
}
if (intMinutes < 10){
minutes ="0"+intMinutes+":";
} else{
minutes =intMinutes+":";
}
if (intSeconds < 10){
seconds = "0"+intSeconds+"";
} else{
seconds = intSeconds+"";
}
timeString =xfile+hours+minutes+seconds;
Clock.innerHTML =timeString;
window.setTimeout("tick();",100);
}
window.onload =tick;
</script>
第二步.将下面的代码加入html文件任意需要的地方
<div id="Clock" align="center"></div>
你可以自行更改样式!
二、显示年月日格式的时间代码 如:2008年11月27日 星期四
XML/HTML代码
<scriptlanguage=javascript>
today=newDate();
functioninitArray(){
this.length=initArray.arguments.length
for(vari=0;i<this.length;i++)
this[i+1]=initArray.arguments[i]}
var d=newinitArray(
"星期日",
"星期一",
"星期二",
"星期三",
"星期四",
"星期五",
"星期六");
document.write(
"<font color=##000000style='font-size:9pt;font-family: 宋体'>",
today.getYear(),"年",
today.getMonth()+1,"月",
today.getDate(),"日",
d[today.getDay()+1],
"</font>");
</script>
三、显示日期,星期,时间格式的代码 如:2008年11月27日星期四 下午2:17:36
XML/HTML代码
<SCRIPT language=JavaScript>
today=new Date();
function initArray(){
this.length=initArray.arguments.length
for(vari=0;i<this.length;i++)
this[i+1]=initArray.arguments[i] }
var d=new initArray(
"星期日",
"星期一",
"星期二",
"星期三",
"星期四",
"星期五",
"星期六");
document.write(
"<font color=#ecc1c1style='font-size:9pt;font-family: 宋体'> ",
today.getYear(),"年",
today.getMonth()+1,"月",
today.getDate(),"日",
d[today.getDay()+1],
"</font>" );
</SCRIPT>
</TD>
<TD class=bai align=leftwidth=95>
<SCRIPT language=JavaScript>
function tick() {
var hours, minutes, seconds, xfile;
var intHours, intMinutes, intSeconds;
var today;
today = new Date();
intHours = today.getHours();
intMinutes = today.getMinutes();
intSeconds = today.getSeconds();
if (intHours == 0) {
hours = "12:";
xfile = "午夜";
} else if (intHours < 12) {
hours = intHours+":";
xfile = "上午";
} else if (intHours == 12) {
hours = "12:";
xfile = "正午";
} else {
intHours = intHours - 12
hours = intHours + ":";
xfile = "下午";
}
if (intMinutes < 10) {
minutes = "0"+intMinutes+":";
} else {
minutes = intMinutes+":";
}
if (intSeconds < 10) {
seconds = "0"+intSeconds+" ";
} else {
seconds = intSeconds+" ";
}
timeString = xfile+hours+minutes+seconds;
Clock.innerHTML = timeString;
window.setTimeout("tick();", 100);
}
window.onload = tick;
</SCRIPT>
<DIV id=Clockalign=center></DIV>
四、显示来访者的停留时间 如:停留时间: 00:15
XML/HTML代码
<scriptlanguage="javascript">
var ap_name =navigator.appName;
var ap_vinfo =navigator.appVersion;
var ap_ver =parseFloat(ap_vinfo.substring(0,ap_vinfo.indexOf('(')));
var time_start = newDate();
var clock_start =time_start.getTime();
vardl_ok=false;
function init()
{
if(ap_name=="Netscape" &&ap_ver>=3.0)
dl_ok=true;
returntrue;
}
function get_time_spent()
{
var time_now = newDate();
return((time_now.getTime() -clock_start)/1000);
}
function show_secs () // show the time user spent on theside
{
var i_total_secs =Math.round(get_time_spent());
var i_secs_spent = i_total_secs %60;
var i_mins_spent =Math.round((i_total_secs-30)/60);
var s_secs_spent = "" + ((i_secs_spent>9) ?i_secs_spent : "0" +i_secs_spent);
var s_mins_spent = "" + ((i_mins_spent>9) ?i_mins_spent : "0" +i_mins_spent);
document.fm0.time_spent.value = s_mins_spent + ":" +s_secs_spent;
window.setTimeout('show_secs()',1000);
}
// -->
</script>
<FORM name="fm0"onSubmit="0"><FONTCOLOR="#6060FF">停留时间:
</FONT><INPUTtype="text" name="time_spent" size=7onFocus="this.blur()"></FORM>
而且还要在你主页源文件<body>中加入下面的代码
<BODY onLoad="init();window.setTimeout('show_secs()',1);">
五、显示当前日期与时间 如:现在是: 2008年11月27日 14:18:59 时间不走动
XML/HTML代码
<scriptlanguage="javascript">
<!--
now = newDate()
hour =now.getHours()
if (hour < 12){
document.write("现在是: " +now.toLocaleString())
} else if (hour <18){
document.write("现在是: " +now.toLocaleString())
} else if (hour >= 18){
document.write("现在是: " +now.toLocaleString())
}
//--></script>
六、浏览器状态栏显示的时钟 如:2:20 P.M. 星期四 在状态栏显示
XML/HTML代码
<BODY onLoad="run();timerONE=window.setTimeout"></BODY>
<SCRIPTLANGUAGE="javascript">
<!--Hide
timeID =null;
timeRunning =false;
function stop (){
if(timeRunning)
clearTimeout(timeID);
timeRunning =false;
}
function time (){
tick = newDate();
hours =tick.getHours();
minutes =tick.getMinutes();
seconds =tick.getSeconds();
day =tick.getDay();
month =tick.getMonth();
date =tick.getDate();
year =tick.getYear();
current = "" + ((hours >12) ? hours -12:hours)
current += ((minutes < 10) ? ":0" : ":") +minutes
current += ((seconds < 10) ? ":0" : ":") +seconds
current += (hours >= 12) ? " P.M." : "A.M."
if(day==0){var weekday = "星期日"}
if(day==1){var weekday = "星期一"}
if(day==2){var weekday = "星期二"}
if(day==3){var weekday = "星期三"}
if(day==4){var weekday = "星期四"}
if(day==5){var weekday = "星期五"}
if(day==6){var weekday = "星期六"}
current+=(weekday)
window.status=current;
timeID =setTimeout("time()",1000);
timeRunning =true;
}
functionrun(){
stop();
time();
}
//-->
</SCRIPT>
七、显示最后更新时间代码 如:最后更新时间: 11/27/2008 14:21:04
XML/HTML代码
<SCRIPTlanguage=javascript>
<!--hide script from oldbrowsers
document.write("最后更新时间: " + document.lastModified +"")
// end hiding-->
</SCRIPT>
八、实时走动的数字时钟 如:下午14:22:03
XML/HTML代码
<script>
function tick(){
var hours, minutes, seconds,xfile;
var intHours, intMinutes,intSeconds;
vartoday;
today = newDate();
intHours =today.getHours();
intMinutes =today.getMinutes();
intSeconds =today.getSeconds();
if (intHours == 0){
hours ="12:";
xfile ="午夜";
} else if (intHours < 12){
hours =intHours+":";
xfile ="上午";
} else if (intHours == 12){
hours ="12:";
xfile ="正午";
} else{
intHoursintHours = intHours -12
hours = intHours +":";
xfile ="下午";
}
if (intMinutes < 10){
minutes ="0"+intMinutes+":";
} else{
minutes =intMinutes+":";
}
if (intSeconds < 10){
seconds = "0"+intSeconds+"";
} else{
seconds = intSeconds+"";
}
timeString =xfile+hours+minutes+seconds;
Clock.innerHTML =timeString;
window.setTimeout("tick();",100);
}
window.onload =tick;
</script>
<div id="Clock"></div>
九、根据不同的时间显示不同的问候语 如:午安!
XML/HTML代码
方法:在主页中你需要的地方加入以下代码:
<scriptlanguage="LiveScript">
now = new Date(),hour =now.getHours()
if(hour <6){document.write("明天不用上班了吗?")}
else if (hour <8){document.write("全新的一天!")}
else if (hour <12){document.write("早安!")}
else if (hour <14){document.write("外面太阳大吗?")}
else if (hour <18){document.write("午安!")}
else if (hour <22){document.write("晚上好!")}
else if (hour < 24){document.write("夜深了! 要注意身体呀!祝你做个好梦!")}
// -->
</script>
说明,可以自行修改出更好更多的问候语!
十、显示年月日星期及农历的月和日 如:2008年11月27日 星期四 农历 10月30日
第一步:将一下代码保存为.JS文件
XML/HTML代码
<!--
functionCalConv()
{
FIRSTYEAR =1998;
LASTYEAR =2031;
today = newDate();
SolarYear =today.getFullYear();
SolarMonth =today.getMonth() +1;
SolarDate =today.getDate();
Weekday =today.getDay();
LunarCal =[
new tagLunarCal( 27, 5, 3, 43,1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 1, 0, 1),
new tagLunarCal( 46, 0, 4, 48,1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 0, 1 ),
new tagLunarCal( 35, 0, 5, 53,1, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1 ),
new tagLunarCal( 23, 4, 0, 59,1, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1),
new tagLunarCal( 42, 0,1, 4, 1, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1),
new tagLunarCal( 31, 0,2, 9, 1, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0),
new tagLunarCal( 21, 2, 3, 14,0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1 ),
new tagLunarCal( 39, 0, 5, 20,0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1),
new tagLunarCal( 28, 7, 6, 25,1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 1),
new tagLunarCal( 48, 0, 0, 30,0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 0, 1, 1),
new tagLunarCal( 37, 0, 1, 35,1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1 ),
new tagLunarCal( 25, 5, 3, 41,1, 1, 0, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1),
new tagLunarCal( 44, 0, 4, 46,1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1),
new tagLunarCal( 33, 0, 5, 51,1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1),
new tagLunarCal( 22, 4, 6, 56,1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0 ),
new tagLunarCal( 40, 0,1, 2, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0),
new tagLunarCal( 30, 9,2, 7, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1),
new tagLunarCal( 49, 0, 3, 12,0, 1, 0, 0, 1, 0, 1, 1, 1, 0, 1, 0, 1),
new tagLunarCal( 38, 0, 4, 17,1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1, 0 ),
new tagLunarCal( 27, 6, 6, 23,0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1),
new tagLunarCal( 46, 0, 0, 28,0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 0),
new tagLunarCal( 35, 0, 1, 33,0, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0),
new tagLunarCal( 24, 4, 2, 38,0, 1, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1 ),
new tagLunarCal( 42, 0, 4, 44,0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1),
new tagLunarCal( 31, 0, 5, 49,1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0),
new tagLunarCal( 21, 2, 6, 54,0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1),
new tagLunarCal( 40, 0, 0, 59,0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1, 0, 1 ),
new tagLunarCal( 28, 6,2, 5, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0),
new tagLunarCal( 47, 0, 3, 10,1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 1, 0, 1),
new tagLunarCal( 36, 0, 4, 15,1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1),
new tagLunarCal( 25, 5, 5, 20,1, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0 ),
new tagLunarCal( 43, 0, 0, 26,1, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1),
new tagLunarCal( 32, 0, 1, 31,1, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 0),
new tagLunarCal( 22, 3, 2, 36,0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0 )];
SolarCal = [ 31, 28, 31, 30, 31, 30, 31, 31, 30,31, 30, 31];
SolarDays = [ 0, 31, 59, 90, 120, 151, 181, 212,243, 273, 304, 334, 365, 396, 0, 31, 60, 91, 121,152, 182, 213, 244, 274, 305, 335, 366, 397];
AnimalIdx =["马", "羊", "猴", "鸡", "狗", "猪", "鼠", "牛", "虎", "兔", "龙", "蛇"];
LocationIdx= [ "南", "东", "北", "西"];
if (SolarYear <= FIRSTYEAR || SolarYear >LASTYEAR ) return1;
sm =SolarMonth -1;
if ( sm < 0 || sm > 11 ) return2;
leap = GetLeap( SolarYear);
if ( sm == 1)
d = leap +28;
else
d =SolarCal[sm];
if (SolarDate < 1 || SolarDate > d )return3;
y =SolarYear -FIRSTYEAR;
acc =SolarDays[ leap*14 + sm ] +SolarDate;
kc = acc +LunarCal[y].BaseKanChih;
Kan = kc %10;
Chih = kc %12;
Location =LocationIdx[kc %4];
Age = kc %60;
if ( Age< 22)
Age = 22 -Age;
else
Age = 82 -Age;
Animal =AnimalIdx[ Chih];
if ( acc<= LunarCal[y].BaseDays ){
y--;
LunarYear = SolarYear -1;
leap = GetLeap( LunarYear);
sm +=12;
acc = SolarDays[leap*14 + sm] +SolarDate;
}
else
LunarYear =SolarYear;
l1 =LunarCal[y].BaseDays;
for ( i=0;i<13; i++ ){
l2 = l1 + LunarCal[y].MonthDays[i] +29;
if ( acc <= l2 )break;
l1 =l2;
}
LunarMonth =i +1;
LunarDate =acc -l1;
im =LunarCal[y].Intercalation;
if ( im != 0&& LunarMonth > im ){
LunarMonth--;
if ( LunarMonth == im ) LunarMonth =-im;
}
if (LunarMonth > 12 ) LunarMonth -=12;
today=newDate();
functioninitArray(){
this.length=initArray.arguments.length
for(vari=0;i<this.length;i++)
this[i+1]=initArray.arguments[i]}
var d=newinitArray("星期日","星期一","星期二","星期三","星期四","星期五","星期六");
document.write("<spanclass="jsdhtml"> ",today.getYear(),"年",today.getMonth()+1,"月",today.getDate(),"日",d[today.getDay()+1],"");
document.write( "<spanclass="jsdhtml"> 农历 " + LunarMonth + "月" +LunarDate +"日");
return0;
}
function GetLeap( year)
{
if ( year % 400 == 0)
return1;
else if ( year % 100 == 0)
return0;
else if ( year % 4 == 0)
return1;
else
return0;
}
function tagLunarCal( d, i, w, k, m1, m2, m3, m4, m5, m6, m7, m8,m9, m10, m11, m12, m13){
this.BaseDays =d;
this.Intercalation =i;
this.BaseWeekday =w;
this.BaseKanChih =k;
this.MonthDays = [ m1, m2, m3, m4, m5, m6, m7,m8, m9, m10, m11, m12, m13 ];
}
//-->
CalConv();
第二步:在你网页所需要的地方插入调用代码
XML/HTML代码
<script language=javascriptsrc="刚才命名.js"></script>
十一、根据不同的时候显示不同的问候+后面跟着一句不变的话 如:下午好! ……
XML/HTML代码
<SCRIPTlanguage=JavaScript><!--
varwelcomestring;
var mydate = newDate();
var myyear =mydate.getYear();
if(myyear < 300)myyear = 1900 + myyear;
mymonth =mydate.getMonth()+1;
today =mydate.getDate();
myhour =mydate.getHours();
if(myhour<6)
welcomestring="凌晨好";
elseif(myhour<9)
welcomestring="早上好";
elseif(myhour<12)
welcomestring="上午好";
elseif(myhour<14)
welcomestring="中午好";
elseif(myhour<17)
welcomestring="下午好";
elseif(myhour<19)
welcomestring="傍晚好";
elseif(myhour<22)
welcomestring="晚上好";
else
welcomestring="夜里好";
document.writeln(welcomestring+ "!欢迎访问公安县夹竹园镇北湖渔场网站");
//-->
</SCRIPT>
十二、显示年月日星期及今年的第几周 如:2008年11月27日 星期四 今年的第44周
XML/HTML代码
<scriptlanguage=JavaScript>
function weekOfYear(year, month,day){
var date1 = new Date(year, 0,1);
var date2 = new Date(year, month-1, day,1);
var dayMS =24*60*60*1000;
var firstDay =(7-date1.getDay())*dayMS;
var weekMS =7*dayMS;
date1date1 =date1.getTime();
date2date2 =date2.getTime();
returnMath.ceil((date2-date1-firstDay)/weekMS)+1;
}
today=newDate();
functioninitArray(){
this.length=initArray.arguments.length;
for(vari=0;i<this.length;i++)
this[i+1]=initArray.arguments[i]
}
var d=newinitArray("星期日","星期一","星期二","星期三","星期四","星期五","星期六");
document.write("<fontstyle='font-size:9pt;font-family:宋体'>",today.getYear(),"年",today.getMonth()+1,"月",today.getDate(),"日",d[today.getDay()+1],"今年的第",weekOfYear(today.getYear(),today.getMonth(),today.getDate()),"周","</font>");
</script>
十三、显示年月日、农历月日及星期 如:2008年11月27日 农历十月三十 星期四
XML/HTML代码
<script type="text/javascript">varnow=newDate();</script>
<scriptlanguage=javascript>
var lunarinfo=newArray(0x04bd8,0x04ae0,0x0a570,0x054d5,0x0d260,0x0d950,0x16554,0x056a0,0x09ad0,0x055d2,
0x04ae0,0x0a5b6,0x0a4d0,0x0d250,0x1d255,0x0b540,0x0d6a0,0x0ada2,0x095b0,0x14977,
0x04970,0x0a4b0,0x0b4b5,0x06a50,0x06d40,0x1ab54,0x02b60,0x09570,0x052f2,0x04970,
0x06566,0x0d4a0,0x0ea50,0x06e95,0x05ad0,0x02b60,0x186e3,0x092e0,0x1c8d7,0x0c950,
0x0d4a0,0x1d8a6,0x0b550,0x056a0,0x1a5b4,0x025d0,0x092d0,0x0d2b2,0x0a950,0x0b557,
0x06ca0,0x0b550,0x15355,0x04da0,0x0a5d0,0x14573,0x052d0,0x0a9a8,0x0e950,0x06aa0,
0x0aea6,0x0ab50,0x04b60,0x0aae4,0x0a570,0x05260,0x0f263,0x0d950,0x05b57,0x056a0,
0x096d0,0x04dd5,0x04ad0,0x0a4d0,0x0d4d4,0x0d250,0x0d558,0x0b540,0x0b5a0,0x195a6,
0x095b0,0x049b0,0x0a974,0x0a4b0,0x0b27a,0x06a50,0x06d40,0x0af46,0x0ab60,0x09570,
0x04af5,0x04970,0x064b0,0x074a3,0x0ea50,0x06b58,0x055c0,0x0ab60,0x096d5,0x092e0,
0x0c960,0x0d954,0x0d4a0,0x0da50,0x07552,0x056a0,0x0abb7,0x025d0,0x092d0,0x0cab5,
0x0a950,0x0b4a0,0x0baa4,0x0ad50,0x055d9,0x04ba0,0x0a5b0,0x15176,0x052b0,0x0a930,
0x07954,0x06aa0,0x0ad50,0x05b52,0x04b60,0x0a6e6,0x0a4e0,0x0d260,0x0ea65,0x0d530,
0x05aa0,0x076a3,0x096d0,0x04bd7,0x04ad0,0x0a4d0,0x1d0b6,0x0d250,0x0d520,0x0dd45,
0x0b5a0,0x056d0,0x055b2,0x049b0,0x0a577,0x0a4b0,0x0aa50,0x1b255,0x06d20,0x0ada0);
var animals=newArray("鼠","牛","虎","兔","龙","蛇","马","羊","猴","鸡","狗","猪");
var gan=newArray("甲","乙","丙","丁","戊","己","庚","辛","壬","癸");
var zhi=newArray("子","丑","寅","卯","辰","巳","午","未","申","酉","戌","亥");
//var now = newDate(2008,3,27);
var sy =now.getFullYear();
var sm =now.getMonth();
var sd =now.getDate();
var xq =now.getDay();
//==== 传入 offset 传回干支,0=甲子
function cyclical(num) {return(gan[num]+zhi[num])}
//==== 传回农历y年的总天数
function lyeardays(y){
var i, sum = 348
for(i=0x8000; i>0x8;i>>=1) sum += (lunarinfo[y-1900]& i)? 1:0
return(sum+leapdays(y))
}
//==== 传回农历y年闰月的天数
function leapdays(y){
if(leapmonth(y)) return((lunarinfo[y-1900] &0x10000)? 30:29)
elsereturn(0)
}
//==== 传回农历 y年闰哪个月 1-12 , 没闰传回0
function leapmonth(y) { return(lunarinfo[y-1900] &0xf)}
//====================================== 传回农历y年m月的总天数
function monthdays(y,m) { return( (lunarinfo[y-1900]& (0x10000>>m))? 30:29 )}
//==== 算出农历, 传入日期物件,传回农历日期物件
// 该物件属性有 .year .month .day .isleap .yearcyl .daycyl.moncyl
function lunar(objdate){
var i, leap=0, temp=0
var basedate = newDate(1900,0,31)
var offset = (objdate -basedate)/86400000
this.daycyl = offset +40
this.moncyl = 14
for(i=1900; i<2050&& offset>0; i++){
temp =lyeardays(i)
offset -= temp
this.moncyl +=12
}
if(offset<0){
offset +=temp;
i--;
this.moncyl -= 12
}
this.year =i
this.yearcyl =i-1864
leap = leapmonth(i)//闰哪个月
this.isleap = false
for(i=1; i<13 &&offset>0; i++){
//闰月
if(leap>0 &&i==(leap+1) &&this.isleap==false)
{ --i; this.isleap = true; temp = leapdays(this.year);}
else
{ temp = monthdays(this.year, i);}
//解除闰月
if(this.isleap==true &&i==(leap+1)) this.isleap =false
offset -= temp
if(this.isleap == false) this.moncyl++
}
if(offset==0 &&leap>0 &&i==leap+1)
if(this.isleap)
{ this.isleap = false;}
else
{ this.isleap = true; --i;--this.moncyl;}
if(offset<0){ offset += temp; --i; --this.moncyl;}
this.month =i
this.day = offset +1
}
functionyymmdd(){
var cl = '<font color="#ff0000">';
if (now.getday() == 0) cl = '<font color="#c00000">';
if (now.getday() == 6) cl = '<font color="#00c000">';
return(cl+sy+'年'+(sm+1)+'月'+sd+'日</font>');
}
functionweekday(){
myArray = newArray(6);
myArray[0] ="星期日"
myArray[1] ="星期一"
myArray[2] ="星期二"
myArray[3] ="星期三"
myArray[4] ="星期四"
myArray[5] ="星期五"
myArray[6] ="星期六"
weekday =now.getDay();
document.write(myArray[weekday])
}
functioncday(m,d){
var nstr1 = newArray('日','一','二','三','四','五','六','七','八','九','十');
var nstr2 = newArray('初','十','廿','卅',' ');
vars;
if (m>10){s = '十'+nstr1[m-10]}else {s = nstr1[m]} s +='月'
if (s=="十二月") s ="腊月";
if (s=="一月") s ="正月";
switch (d){
case 10:s += '初十';break;
case 20:s += '二十';break;
case 30:s += '三十';break;
default:s += nstr2[Math.floor(d/10)]; s +=nstr1[d];
}
return(s);
}
functionsolarday1(){
var sdobj = newDate(sy,sm,sd);
var ldobj = newlunar(sdobj);
var cl = '<font color="violet">';
var tt = '【'+animals[(sy-4)]+'】'+cyclical(ldobj.moncyl)+'月'+cyclical(ldobj.daycyl++)+'日';
document.write(cl+tt+'</font>');
}
functionsolarday2(){
var sdobj = newDate(sy,sm,sd);
var ldobj = newlunar(sdobj);
var cl ='';
//农历bb'+(cld[d].isleap?'闰 ':' ')+cld[d].lmonth+' 月 '+cld[d].lday+'日
var tt =cday(ldobj.month,ldobj.day);
document.write('农历'+tt+'');
}
functionsolarday3(){
var sterminfo = newArray(0,21208,42467,63836,85337,107014,128867,150921,173149,195551,218072,240693,263343,285989,308563,331033,353350,375494,397447,419210,440795,462224,483532,504758)
var solarterm = newArray("小寒","大寒","立春","雨水","惊蛰","春分","清明","谷雨","立夏","小满","芒种","夏至","小暑","大暑","立秋","处暑","白露","秋分","寒露","霜降","立冬","小雪","大雪","冬至")
var lftv = new Array("0101*春节","0115 元宵节","0505 端午节","0707七夕情人节","0715 中元节","0815 中秋节","0909 重阳节","1208 腊八节","1224小年","0100*除夕")
var sftv = new Array("0101*元旦","0214 情人节","0308 妇女节","0309偶今天又长一岁拉","0312 植树节","0315 消费者权益日","0401 愚人节","0418 mm的生日","0501劳动节","0504 青年节","0512 护士节","0601 儿童节","0701 建党节香港回归纪念",
"0801 建军节","0808 父亲节","0909 毛泽东逝世纪念","0910 教师节","0928孔子诞辰","1001*国庆节",
"1006 老人节","1024 联合国日","1112 孙中山诞辰","1220 澳门回归纪念","1225 圣诞节","1226毛泽东诞辰")
var sdobj = newDate(sy,sm,sd);
var ldobj = newlunar(sdobj);
var ldpos = newArray(3);
varfestival='',solarterms='',solarfestival='',lunarfestival='',tmp1,tmp2;
//农历节日
for(i inlftv)
if(lftv[i].match(/^(d{2})(.{2})([s*])(.+)$/)){
tmp1=number(regexp.$1)-ldobj.month
tmp2=number(regexp.$2)-ldobj.day
if(tmp1==0 && tmp2==0)lunarfestival=regexp.$4
}
//国历节日
for(i insftv)
if(sftv[i].match(/^(d{2})(d{2})([s*])(.+)$/)){
tmp1=number(regexp.$1)-(sm+1)
tmp2=number(regexp.$2)-sd
if(tmp1==0 && tmp2==0)solarfestival =regexp.$4
}
//节气
tmp1 = newdate((31556925974.7*(sy-1900)+sterminfo[sm*2+1]*60000)+date.utc(1900,0,6,2,5))
tmp2 =tmp1.getutcdate()
if (tmp2==sd) solartermsolarterms =solarterm[sm*2+1]
tmp1 = newdate((31556925974.7*(sy-1900)+sterminfo[sm*2]*60000)+date.utc(1900,0,6,2,5))
tmp2=tmp1.getutcdate()
if (tmp2==sd) solartermsolarterms =solarterm[sm*2]
if(solarterms == '' &&solarfestival == '' &&lunarfestival =='')
festival ='';
else
festival = '<table width=100% border=0 cellpadding=2cellspacing=0bgcolor="#ccffcc"><tr><td>'+
'<font color="#000000">'+solarterms + ' ' +solarfestival + ' ' +lunarfestival+'</font></td>'+
'</tr></table>';
var cl = '<font color="#000066">';
//document.write(cl+festival+'</font>');
alert(cl+festival);
}
functionsetcalendar(){
document.write('<table align=center cellpadding=2cellspacing=0border=1><tr><tdbgcolor=#fefeef><table border=0cellpadding=0cellspacing=0><tr><tdalign=center>');
document.write(yymmdd()+''+weekday());
document.write('</td></tr>');
document.write('<tr><tdalign=center>');
document.write(solarday1());
document.write('</td></tr><tr><tdalign=center>');
document.write(solarday2());
document.write('</td></tr><tr><td>');
document.write(solarday3());
document.write('</td></tr></table></td></tr></table>');
}
</script>
<scripttype="text/javascript">document.write(now.getFullYear()+"年"+(now.getMonth()+1)+"月"+now.getDate()+"日");</script><script language="javascript"type="text/javascript">solarday2();</script><script language="javascript"type="text/javascript">weekday();</script>
十四、显示大写的年月日 如:二○○八年十一月二十一日
XML/HTML代码
<SCRIPTLANGUAGE="JavaScript">
<!--
document.write((newDate()).getYear().toString().replace(/1/gi,"一").replace(/2/gi,"二").replace(/3/gi,"三").replace(/4/gi,"四").replace(/5/gi,"五").replace(/6/gi,"六").replace(/7/gi,"七").replace(/8/gi,"八").replace(/9/gi,"九").replace(/0/gi,"○")+"年");
document.write(("一,二,三,四,五,六,七,八,九,十,十一,十二".split(","))[(newDate()).getMonth()]+"月");
document.write(("一,二,三,四,五,六,七,八,九,十,十一,十二,十三,十四,十五,十六,十七,十八,十九,二十,二十一,二十二,二十三,二十四,二十五,二十六,二十七,二十八,二十九,三十,三十一".split(","))[(newDate()).getDate()-1]+"日");
//-->
</SCRIPT>
十五、显示年月日、时间及星期 如:2008年11月22日 10:10:58 星期六
XML/HTML代码
<script language="javascript"type="text/javascript">
functionsetTime()
{
var dt=newDate();
var arr_week=newArray("星期日","星期一","星期二","星期三","星期四","星期五", "星期六");
varweek=arr_week[dt.getDay()];
time.innerHTML=dt.toLocaleString()+""+week;
}
setInterval("setTime()",1000);
</script>
<divid="time"></div>
十六、显示年月日、星期及农历XX年 XX月XX日 如:2008年11月27日 星期四农历戊子年 十月三十
XML/HTML代码
<SCRIPT language=JavaScript >
function RunGLNL(){
var today=new Date();
var d=new Array("星期日","星期一","星期二","星期三","星期四","星期五","星期六");
var DDDD=(today.getYear()<100 ?today.getYear()+1900:today.getYear())+"年"+(today.getMonth()+1)+"月"+today.getDate()+"日";
DDDD = DDDD + " " + d[today.getDay()];
DDDD = DDDD+" "+ (CnDateofDateStr(today));
//DDDD = DDDD+ " " + SolarTerm(today);
document.write(DDDD);
}
function DaysNumberofDate(DateGL){
returnparseInt((Date.parse(DateGL)-Date.parse(DateGL.getYear()+"/1/1"))/86400000)+1;
}
function CnDateofDate(DateGL){
var CnData=new Array(
0x16,0x2a,0xda,0x00,0x83,0x49,0xb6,0x05,0x0e,0x64,0xbb,0x00,0x19,0xb2,0x5b,0x00,
0x87,0x6a,0x57,0x04,0x12,0x75,0x2b,0x00,0x1d,0xb6,0x95,0x00,0x8a,0xad,0x55,0x02,
0x15,0x55,0xaa,0x00,0x82,0x55,0x6c,0x07,0x0d,0xc9,0x76,0x00,0x17,0x64,0xb7,0x00,
0x86,0xe4,0xae,0x05,0x11,0xea,0x56,0x00,0x1b,0x6d,0x2a,0x00,0x88,0x5a,0xaa,0x04,
0x14,0xad,0x55,0x00,0x81,0xaa,0xd5,0x09,0x0b,0x52,0xea,0x00,0x16,0xa9,0x6d,0x00,
0x84,0xa9,0x5d,0x06,0x0f,0xd4,0xae,0x00,0x1a,0xea,0x4d,0x00,0x87,0xba,0x55,0x04
);
var CnMonth=new Array();
var CnMonthDays=new Array();
var CnBeginDay;
var LeapMonth;
var Bytes=new Array();
var I;
var CnMonthData;
var DaysCount;
var CnDaysCount;
var ResultMonth;
var ResultDay;
var yyyy=DateGL.getYear();
var mm=DateGL.getMonth()+1;
var dd=DateGL.getDate();
if(yyyy<100) yyyy+=1900;
if ((yyyy < 1997) || (yyyy> 2020)){
return0;
}
Bytes[0] = CnData[(yyyy - 1997) * 4];
Bytes[1] = CnData[(yyyy - 1997) * 4 + 1];
Bytes[2] = CnData[(yyyy - 1997) * 4 + 2];
Bytes[3] = CnData[(yyyy - 1997) * 4 + 3];
if ((Bytes[0] & 0x80) != 0){CnMonth[0] = 12;}
else {CnMonth[0] = 11;}
CnBeginDay = (Bytes[0] &0x7f);
CnMonthData = Bytes[1];
CnMonthData = CnMonthData<< 8;
CnMonthData = CnMonthData | Bytes[2];
LeapMonth = Bytes[3];
for (I=15;I>=0;I--){
CnMonthDays[15 - I] = 29;
if (((1<< I) & CnMonthData)!= 0 ){
CnMonthDays[15 - I]++;}
if(CnMonth[15 - I] == LeapMonth ){
CnMonth[15 - I + 1] = - LeapMonth;}
else{
if (CnMonth[15 - I] < 0 ){CnMonth[15 - I + 1] = -CnMonth[15 - I] + 1;}
else {CnMonth[15 - I + 1] = CnMonth[15 - I] + 1;}
if (CnMonth[15 - I + 1] > 12 ){ CnMonth[15 - I + 1]= 1;}
}
}
DaysCount = DaysNumberofDate(DateGL) - 1;
if (DaysCount <= (CnMonthDays[0]- CnBeginDay)){
if ((yyyy> 1901) &&(CnDateofDate(new Date((yyyy - 1)+"/12/31")) <0)){
ResultMonth = - CnMonth[0];}
else{ResultMonth = CnMonth[0];}
ResultDay =CnBeginDay + DaysCount;
}
else{
CnDaysCount= CnMonthDays[0] - CnBeginDay;
I = 1;
while((CnDaysCount < DaysCount)&& (CnDaysCount + CnMonthDays[I]< DaysCount)){
CnDaysCount+= CnMonthDays[I];
I++;
}
ResultMonth= CnMonth[I];
ResultDay =DaysCount - CnDaysCount;
}
if (ResultMonth > 0){
returnResultMonth * 100 + ResultDay;}
else{return ResultMonth * 100 -ResultDay;}
}
function CnYearofDate(DateGL){
var YYYY=DateGL.getYear();
var MM=DateGL.getMonth()+1;
var CnMM=parseInt(Math.abs(CnDateofDate(DateGL))/100);
if(YYYY<100) YYYY+=1900;
if(CnMM>MM) YYYY--;
YYYY-=1864;
return CnEra(YYYY)+"年";
}
function CnMonthofDate(DateGL){
var CnMonthStr=newArray("零","正","二","三","四","五","六","七","八","九","十","十一","十二");
var Month;
Month =parseInt(CnDateofDate(DateGL)/100);
if (Month < 0){return "闰" +CnMonthStr[-Month] + "月";}
else{return CnMonthStr[Month] + "月";}
}
function CnDayofDate(DateGL){
var CnDayStr=new Array("零",
"初一", "初二","初三", "初四", "初五",
"初六", "初七","初八", "初九", "初十",
"十一", "十二","十三", "十四", "十五",
"十六", "十七","十八", "十九", "二十",
"廿一", "廿二","廿三", "廿四", "廿五",
"廿六", "廿七","廿八", "廿九", "三十");
var Day;
Day = (Math.abs(CnDateofDate(DateGL)))0;
return CnDayStr[Day];
}
function DaysNumberofMonth(DateGL){
var MM1=DateGL.getYear();
MM1<100 ? MM1+=1900:MM1;
var MM2=MM1;
MM1+="/"+(DateGL.getMonth()+1);
MM2+="/"+(DateGL.getMonth()+2);
MM1+="/1";
MM2+="/1";
return parseInt((Date.parse(MM2)-Date.parse(MM1))/86400000);
}
function CnEra(YYYY){
var Tiangan=newArray("甲","乙","丙","丁","戊","己","庚","辛","壬","癸");
//var Dizhi=newArray("子(鼠)","丑(牛)","寅(虎)","卯(兔)","辰(龙)","巳(蛇)",
//"午(马)","未(羊)","申(猴)","酉(鸡)","戌(狗)","亥(猪)");
var Dizhi=newArray("子","丑","寅","卯","辰","巳","午","未","申","酉","戌","亥");
return Tiangan[YYYY]+Dizhi[YYYY];
}
function CnDateofDateStr(DateGL){
if(CnMonthofDate(DateGL)=="零月") return" 请调整您的计算机日期!";
else return "农历"+CnYearofDate(DateGL)+ " " +CnMonthofDate(DateGL) + CnDayofDate(DateGL);
}
function SolarTerm(DateGL){
var SolarTermStr=new Array(
"小寒","大寒","立春","雨水","惊蛰","春分",
"清明","谷雨","立夏","小满","芒种","夏至",
"小暑","大暑","立秋","处暑","白露","秋分",
"寒露","霜降","立冬","小雪","大雪","冬至");
var DifferenceInMonth=new Array(
1272060,1275495,1281180,1289445,1299225,1310355,
1321560,1333035,1342770,1350855,1356420,1359045,
1358580,1355055,1348695,1340040,1329630,1318455,
1306935,1297380,1286865,1277730,1274550,1271556);
var DifferenceInYear=31556926;
var BeginTime=new Date(1901/1/1);
BeginTime.setTime(947120460000);
for(;DateGL.getYear()<BeginTime.getYear();){
BeginTime.setTime(BeginTime.getTime()-DifferenceInYear*1000);
}
for(;DateGL.getYear()>BeginTime.getYear();){
BeginTime.setTime(BeginTime.getTime()+DifferenceInYear*1000);
}
for(varM=0;DateGL.getMonth()>BeginTime.getMonth();M++){
BeginTime.setTime(BeginTime.getTime()+DifferenceInMonth[M]*1000);
}
if(DateGL.getDate()>BeginTime.getDate()){
BeginTime.setTime(BeginTime.getTime()+DifferenceInMonth[M]*1000);
M++;
}
if(DateGL.getDate()>BeginTime.getDate()){
BeginTime.setTime(BeginTime.getTime()+DifferenceInMonth[M]*1000);
M==23?M=0:M++;
}
var JQ;
if(DateGL.getDate()==BeginTime.getDate()){
JQ=" 今天是<fontcolor='#FF9999'><b>"+SolarTermStr[M]+"</b></font>";
}
elseif(DateGL.getDate()==BeginTime.getDate()-1){
JQ=" 明天是<fontcolor='#FF9999'><b>"+SolarTermStr[M]+"</b></font>";
}
elseif(DateGL.getDate()==BeginTime.getDate()-2){
JQ=" 后天是<fontcolor='#FF9999'><b>"+SolarTermStr[M]+"</b></font>";
}
else{
JQ=" "
if(DateGL.getMonth()==BeginTime.getMonth()){
JQ+=" 本月";
}
else{
JQ+=" 下月";
}
JQ+=BeginTime.getDate()+"日"+"<fontcolor='#FF9999'><b>"+SolarTermStr[M]+"</b></font>";
}
return JQ;
}
function CAL()
{}
RunGLNL();
function CurentTime(){
var now =new Date();
var hh =now.getHours();
var mm =now.getMinutes();
var ss =now.getTime() % 60000;
ss = (ss -(ss % 1000)) / 1000;
var clock =hh+':';
if (mm< 10) clock += '0';
clock +=mm+':';
if (ss< 10) clock += '0';
clock +=ss;
return(clock);
}
</SCRIPT>
十七、显示年月日、星期及当前实时走动的时间 如:2008年12月02日 星期二15:50:50
先将以下代码保存为 time.js
XML/HTML代码
var dayarray=newArray("星期日","星期一","星期二","星期三","星期四","星期五","星期六")
var montharray=newArray("01","02","03","04","05","06","07","08","09","10","11","12")
functiongetthedate(){
var mydate=newDate()
varyear=mydate.getYear()
if (year <1000)
year+=1900
varday=mydate.getDay()
varmonth=mydate.getMonth()
vardaym=mydate.getDate()
if(daym<10)
daym="0"+daym
varhours=mydate.getHours()
varminutes=mydate.getMinutes()
varseconds=mydate.getSeconds()
//var dn="上午"
//if(hours>=12)
//dn="下午"
//if(hours>12){
//hourshours=hours-12
//}
//if(hours==0)
//hours=12
var dn=""
if(minutes<=9)
minutes="0"+minutes
if(seconds<=9)
seconds="0"+seconds
//change font sizehere
var cdate=" "+year+"年"+montharray[month]+"月"+daym+"日"+""+dayarray[day]+" "+dn+""+hours+":"+minutes+":"+seconds
if(document.all)
document.all.clock.innerHTML=cdate
else
document.write(cdate)
}
if(!document.all)
getthedate()
functiongoforit(){
if(document.all)
setInterval("getthedate()",1000)
}
goforit();
document.write("<spanid=clock></span>");
再在网页显示处插入以下调用代码:
XML/HTML代码
<script src="time.js"type="text/javascript"></script>
十八、只显示农历日期 如:农历三月(小)十八
XML/HTML代码
<SCRIPT type=text/javascript>
var dateInfo=solarDay3();
var nl=new Lunar(new Date());
varmonthAndDAY=cDay(nl.month,Math.floor(nl.day));
var monthType="";
var days=0;
if(nl.isLeap)
days=leapDays(nl.year);
else
days=monthDays(nl.year,nl.month);
if(days<30)
monthType='小';
else
monthType='大';
if(nl.isLeap)
monthType+=' 闰';
</SCRIPT>
<SCRIPT>
document.write("农历"+monthAndDAY.month+"月("+monthType+")"+monthAndDAY.day+"<spanclass="yellow">"+dateInfo.jieqi+"</span></li>");
</SCRIPT>
十九、只显示生肖年及农历日期 如:己丑年 四月十七
先将下面的代码保存为:data.js
XML/HTML代码
<!--
var CalendarData=newArray(100);var madd=new Array(12);var tgString="甲乙丙丁戊己庚辛壬癸";vardzString="子丑寅卯辰巳午未申酉戌亥";var numString="一二三四五六七八九十";varmonString="正二三四五六七八九十冬腊";var weekString="日一二三四五六";varsx="鼠牛虎兔龙蛇马羊猴鸡狗猪";var cYear,cMonth,cDay,TheDate;
CalendarData = newArray(0xA4B,0x5164B,0x6A5,0x6D4,0x415B5,0x2B6,0x957,0x2092F,0x497,0x60C96,0xD4A,0xEA5,0x50DA9,0x5AD,0x2B6,0x3126E,0x92E,0x7192D,0xC95,0xD4A,0x61B4A,0xB55,0x56A,0x4155B,0x25D,0x92D,0x2192B,0xA95,0x71695,0x6CA,0xB55,0x50AB5,0x4DA,0xA5B,0x30A57,0x52B,0x8152A,0xE95,0x6AA,0x615AA,0xAB5,0x4B6,0x414AE,0xA57,0x526,0x31D26,0xD95,0x70B55,0x56A,0x96D,0x5095D,0x4AD,0xA4D,0x41A4D,0xD25,0x81AA5,0xB54,0xB6A,0x612DA,0x95B,
0x49B,0x41497,0xA4B,0xA164B,0x6A5,0x6D4,0x615B4,0xAB6,0x957,0x5092F,
0x497,0x64B,0x30D4A,0xEA5,0x80D65,0x5AC,0xAB6,0x5126D,0x92E,0xC96,0x41A95,0xD4A,0xDA5,0x20B55,0x56A,0x7155B,0x25D,0x92D,0x5192B,0xA95,0xB4A,0x416AA,0xAD5,0x90AB5,0x4BA,0xA5B,0x60A57,0x52B,0xA93,0x40E95);
madd[0]=0;madd[1]=31;madd[2]=59;madd[3]=90;
madd[4]=120;madd[5]=151;madd[6]=181;madd[7]=212;
madd[8]=243;madd[9]=273;madd[10]=304;madd[11]=334;
function GetBit(m,n) { return(m>>n)&1; }
function e2c()
{
TheDate= (arguments.length!=3) ? new Date() : newDate(arguments[0],arguments[1],arguments[2]);
var total,m,n,k;
var isEnd=false;
var tmp=TheDate.getFullYear();
total=(tmp-1921)*365+Math.floor((tmp-1921)/4)+madd[TheDate.getMonth()]+TheDate.getDate()-38;if(TheDate.getYear()%4==0&&TheDate.getMonth()>1){ total++;} for(m=0;;m++){k=(CalendarData[m]<0xfff)?11:12;for(n=k;n>=0;n--){if(total<=29+GetBit(CalendarData[m],n)){isEnd=true;break;}total=total-29-GetBit(CalendarData[m],n);} if(isEnd)break; } cYear=1921 + m;cMonth=k-n+1; cDay=total;if(k==12){if(cMonth==Math.floor(CalendarData[m]/0x10000)+1) {cMonth=1-cMonth;}if(cMonth>Math.floor(CalendarData[m]/0x10000)+1){ cMonth--; } }}
function GetcDateString(){ var tmp="";tmp+=tgString.charAt((cYear-4));
tmp+=dzString.charAt((cYear-4));
tmp+="年 ";
if(cMonth<1) { tmp+="(闰)";tmp+=monString.charAt(-cMonth-1); } else{tmp+=monString.charAt(cMonth-1);}tmp+="月";tmp+=(cDay<11)?"初":((cDay<20)?"十":((cDay<30)?"廿":"三十"));
if (cDay!=0||cDay==10) { tmp+=numString.charAt((cDay-1));} return tmp;}
function GetLunarDay(solarYear,solarMonth,solarDay)
{
if (solarYear<1921 ||solarYear>2020){return "";
}else{solarMonth = (parseInt(solarMonth)>0) ?(solarMonth-1) :11;e2c(solarYear,solarMonth,solarDay); returnGetcDateString();}}
var D=new Date();
var yy=D.getFullYear();
var mm=D.getMonth()+1;
var dd=D.getDate();
var ww=D.getDay();
var ss=parseInt(D.getTime() / 1000);
function CAL(){
document.write("<table border='0' cellspacing='0'cellpadding='0'");
document.write("<tr><tdalign='center'class='b12'><spanclass='b12'>"+GetLunarDay(yy,mm,dd));
document.write("</span></td></tr></table>");
}
-->
然后在网页所需要显示的地方加入如下代码调用:
XML/HTML代码
<script language="JavaScript" type="text/javascript"src="data.js"></script><scriptlanguage="JavaScript"type="text/javascript">CAL();</script>
二十、“亲爱的用户上午好 中午好 下午好 晚上好 ”显示在标题栏中
时间显示在网页中
<html><head><title></title><script language="javascript">function showtimespan(){var dt = new Date();h=dt.getHours();if(h==12) { return "中午好!";}if((h>12) && (h<=18)) { return "下午好!";}if(h>19) { return "晚上好!";}if((h>8) && (h<12)) { return "上午好!";}}function showdate(){var dt = new Date(); m=dt.getMonth()+1;wk=dt.getDay(); d=dt.getDate()+1; y=dt.getFullYear(); document.write (y + "年" + m + "月" + d + "日 星期" + wk + " " ); }function showtime(){var dt = new Date();h=dt.getHours();m=dt.getMinutes();s=dt.getSeconds();tm.innerHTML= h + ":"+ m + ":"+ s;}document.title= "亲爱的用户"+showtimespan();</script></head><body> <script language="javascript" > showdate();</script><span id="tm"></span><script language="javascript" > window.setInterval("showtime()",1000);</script></body></html>