书签 分享 收藏 举报 版权申诉 / 44

类型ASP显示时间代码.docx

  • 文档编号:23202851
  • 上传时间:2023-05-15
  • 格式:DOCX
  • 页数:44
  • 大小:31.02KB

你可以自行更改样式!

二、显示年月日格式的时间代码如:

2008年11月27日星期四

XML/HTML代码

today=newDate();

functioninitArray(){

this.length=initArray.arguments.length

for(vari=0;i

this[i+1]=initArray.arguments[i]}

vard=newinitArray(

"星期日",

"星期一",

"星期二",

"星期三",

"星期四",

"星期五",

"星期六");

document.write(

"

9pt;font-family:

宋体'>",

today.getYear(),"年",

today.getMonth()+1,"月",

today.getDate(),"日",

d[today.getDay()+1],

"");

三、显示日期,星期,时间格式的代码如:

2008年11月27日星期四下午2:

17:

36

XML/HTML代码

today=newDate();

functioninitArray(){

this.length=initArray.arguments.length

for(vari=0;i

this[i+1]=initArray.arguments[i]}

vard=newinitArray(

"星期日",

"星期一",

"星期二",

"星期三",

"星期四",

"星期五",

"星期六");

document.write(

"

9pt;font-family:

宋体'>",

today.getYear(),"年",

today.getMonth()+1,"月",

today.getDate(),"日",

d[today.getDay()+1],

"");

functiontick(){

varhours,minutes,seconds,xfile;

varintHours,intMinutes,intSeconds;

vartoday;

today=newDate();

intHours=today.getHours();

intMinutes=today.getMinutes();

intSeconds=today.getSeconds();

if(intHours==0){

hours="12:

";

xfile="午夜";

}elseif(intHours<12){

hours=intHours+":

";

xfile="上午";

}elseif(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;

12px;COLOR:

#ecc1c1"align=center>

四、显示来访者的停留时间如:

停留时间:

00:

15

XML/HTML代码

varap_name=navigator.appName;

varap_vinfo=navigator.appVersion;

varap_ver=parseFloat(ap_vinfo.substring(0,ap_vinfo.indexOf('(')));

vartime_start=newDate();

varclock_start=time_start.getTime();

vardl_ok=false;

functioninit()

{

if(ap_name=="Netscape"&&ap_ver>=3.0)

dl_ok=true;

returntrue;

}

functionget_time_spent()

{

vartime_now=newDate();

return((time_now.getTime()-clock_start)/1000);

}

functionshow_secs()//showthetimeuserspentontheside

{

vari_total_secs=Math.round(get_time_spent());

vari_secs_spent=i_total_secs%60;

vari_mins_spent=Math.round((i_total_secs-30)/60);

vars_secs_spent=""+((i_secs_spent>9)?

i_secs_spent:

"0"+i_secs_spent);

vars_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);

}

//-->

停留时间:

而且还要在你主页源文件中加入下面的代码

五、显示当前日期与时间如:

现在是:

2008年11月27日14:

18:

59时间不走动

XML/HTML代码

--

now=newDate()

hour=now.getHours()

if(hour<12){

document.write("现在是:

"+now.toLocaleString())

}elseif(hour<18){

document.write("现在是:

"+now.toLocaleString())

}elseif(hour>=18){

document.write("现在是:

"+now.toLocaleString())

}

//-->

六、浏览器状态栏显示的时钟如:

2:

20P.M.星期四在状态栏显示

XML/HTML代码

--Hide

timeID=null;

timeRunning=false;

functionstop(){

if(timeRunning)

clearTimeout(timeID);

timeRunning=false;

}

functiontime(){

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){varweekday="星期日"}

if(day==1){varweekday="星期一"}

if(day==2){varweekday="星期二"}

if(day==3){varweekday="星期三"}

if(day==4){varweekday="星期四"}

if(day==5){varweekday="星期五"}

if(day==6){varweekday="星期六"}

current+=(weekday)

window.status=current;

timeID=setTimeout("time()",1000);

timeRunning=true;

}

functionrun(){

stop();

time();

}

//-->

七、显示最后更新时间代码如:

最后更新时间:

11/27/200814:

21:

04

XML/HTML代码

--hidescriptfromoldbrowsers

document.write("最后更新时间:

"+document.lastModified+"")

//endhiding-->

八、实时走动的数字时钟如:

下午14:

22:

03

XML/HTML代码

20;color:

#000000">

九、根据不同的时间显示不同的问候语如:

午安!

XML/HTML代码

方法:

在主页中你需要的地方加入以下代码:

now=newDate(),hour=now.getHours()

if(hour<6){document.write("明天不用上班了吗?

")}

elseif(hour<8){document.write("全新的一天!

")}

elseif(hour<12){document.write("早安!

")}

elseif(hour<14){document.write("外面太阳大吗?

")}

elseif(hour<18){document.write("午安!

")}

elseif(hour<22){document.write("晚上好!

")}

elseif(hour<24){document.write("夜深了!

要注意身体呀!

祝你做个好梦!

")}

//-->

说明,可以自行修改出更好更多的问候语!

十、显示年月日星期及农历的月和日如:

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=[

newtagLunarCal(27,5,3,43,1,0,0,1,0,0,1,1,0,1,1,0,1),

newtagLunarCal(46,0,4,48,1,0,0,1,0,0,1,0,1,1,1,0,1),/*88*/

newtagLunarCal(35,0,5,53,1,1,0,0,1,0,0,1,0,1,1,0,1),/*89*/

newtagLunarCal(23,4,0,59,1,1,0,1,0,1,0,0,1,0,1,0,1),

newtagLunarCal(42,0,1,4,1,1,0,1,0,1,0,0,1,0,1,0,1),

newtagLunarCal(31,0,2,9,1,1,0,1,1,0,1,0,0,1,0,1,0),

newtagLunarCal(21,2,3,14,0,1,0,1,1,0,1,0,1,0,1,0,1),/*93*/

newtagLunarCal(39,0,5,20,0,1,0,1,0,1,1,0,1,0,1,0,1),

newtagLunarCal(28,7,6,25,1,0,1,0,1,0,1,0,1,1,0,1,1),

newtagLunarCal(48,0,0,30,0,0,1,0,0,1,0,1,1,1,0,1,1),

newtagLunarCal(37,0,1,35,1,0,0,1,0,0,1,0,1,1,0,1,1),/*97*/

newtagLunarCal(25,5,3,41,1,1,0,0,1,0,0,1,0,1,0,1,1),

newtagLunarCal(44,0,4,46,1,0,1,0,1,0,0,1,0,1,0,1,1),

newtagLunarCal(33,0,5,51,1,0,1,1,0,1,0,0,1,0,1,0,1),

newtagLunarCal(22,4,6,56,1,0,1,1,0,1,0,1,0,1,0,1,0),/*101*/

newtagLunarCal(40,0,1,2,1,0,1,1,0,1,0,1,0,1,0,1,0),

newtagLunarCal(30,9,2,7,0,1,0,1,0,1,0,1,1,0,1,0,1),

newtagLunarCal(49,0,3,12,0,1,0,0,1,0,1,1,1,0,1,0,1),

newtagLunarCal(38,0,4,17,1,0,1,0,0,1,0,1,1,0,1,1,0),/*105*/

newtagLunarCal(27,6,6,23,0,1,0,1,0,0,1,0,1,0,1,1,1),

newtagLunarCal(46,0,0,28,0,1,0,1,0,0,1,0,1,0,1,1,0),

newtagLunarCal(35,0,1,33,0,1,1,0,1,0,0,1,0,0,1,1,0),

newtagLunarCal(24,4,2,38,0,1,1,1,0,1,0,0,1,0,1,0,1),/*109*/

newtagLunarCal(42,0,4,44,0,1,1,0,1,0,1,0,1,0,1,0,1),

newtagLunarCal(31,0,5,49,1,0,1,0,1,1,0,1,0,1,0,1,0),

newtagLunarCal(21,2,6,54,0,1,0,1,0,1,0,1,1,0,1,0,1),

newtagLunarCal(

配套讲稿:

如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。

特殊限制:

部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。

关 键  词:
ASP 显示 时间 代码
提示  冰豆网所有资源均是用户自行上传分享,仅供网友学习交流,未经上传用户书面授权,请勿作他用。
关于本文
本文标题:ASP显示时间代码.docx
链接地址:https://www.bdocx.com/doc/23202851.html
关于我们 - 网站声明 - 网站地图 - 资源地图 - 友情链接 - 网站客服 - 联系我们

copyright@ 2008-2022 冰点文档网站版权所有

经营许可证编号:鄂ICP备2022015515号-1

收起
展开