在HTML控件中显示本周周一和本周周日的日期

在HTML控件中显示本周周一和本周周日的日期,第1张

用js的date()啊

<script>

function showtimeInt(){

var Time=new Date()

var day=TimegetUTCDate();

var month=TimegetUTCMonth() + 1;

var year=TimegetUTCFullYear();

var week=TimegetDay();

if(month<10){month="0"+month;}

if(day<

(省略对日期及当前月天数的讨论)

day1-=week;

day2=day+6-week;

documentgetElementById("Mon")innerHTML=year + "-" + month + "-" + day1;

documentgetElementById("Wek")innerHTML=year + "-" + month + "-" + day2; }

$(document)ready(function() {

windowsetInterval('showtimeInt()',1000);

});

</script>

<!--weekdayhtml-->

<script type="text/vbscript">

dim theTime, theDay

theTime = now()

theDay = weekday(theTime)

select case theDay

case 0:

documentwrite("星期天")

case 1:

documentwrite("星期一")

case 2:

documentwrite("星期二")

case 3:

documentwrite("星期三")

case 4:

documentwrite("星期四")

case 5:

documentwrite("星期五")

case 6:

documentwrite("星期六")

end select

</script>

在你的HTML页面,需要显示系统当前时间的地方,插入代码即可:

<php

    echo date('Y-m-d H:i:s',time());

>

这个如何呢?

<SPAN class="heise" id="liveclock"></SPAN><script language="javascript">

function timeprint()

{

var week; var date;

var today=new Date()

var year=todaygetYear()

var month=todaygetMonth()+1

var day=todaygetDate()

var ss=todaygetDay()

var hours=todaygetHours()

var minutes=todaygetMinutes()

var seconds=todaygetSeconds()

date=year+"年"+month+"月"+day+"日 "

if(ss==0) week="星期日"

if(ss==1) week="星期一"

if(ss==2) week="星期二"

if(ss==3) week="星期三"

if(ss==4) week="星期四"

if(ss==5) week="星期五"

if(ss==6) week="星期六"

if(minutes<=9)

minutes="0"+minutes

if(seconds<=9)

seconds="0"+seconds

myclock=date+week+" "+hours+":"+minutes+":"+seconds

if(documentlayers){documentlayersliveclockdocumentwrite(myclock)

documentlayersliveclockdocumentclose()

}else if(documentall)

liveclockinnerHTML=myclock

setTimeout("timeprint()",1000)

}

timeprint();

//-->

</script>

在html里要用js

<!--显示日期的js代码-->

<script type="text/javascript">

<!--

function MM_showHideLayers() { //v60

for (var i=1; i<=1; i++) { //i<=层的数目

layerObj=eval('Layer'+i);

layerObjstylevisibility='hidden';

}

var i,p,v,obj,args=MM_showHideLayersarguments;

for (i=0; i<(argslength-2); i+=3)

if ((obj=MM_findObj(args[i]))!=null) {

v=args[i+2];

if (objstyle) { obj=objstyle; v=(v=='show')'visible':(v=='hide')'hidden':v; }

objvisibility=v;

}

}

function MM_findObj(n, d) { //v401

var p,i,x;

if (!d) d=document;

if ((p=nindexOf(""))>0 && parentframeslength) {

d=parentframes[nsubstring(p+1)]document;

n=nsubstring(0,p);

}

if (!(x=d[n]) && dall) x=dall[n];

for (i=0; !x&&i<dformslength; i++) x=dforms[i][n];

for (i=0; !x&&dlayers&&i<dlayerslength; i++) x=MM_findObj(n,dlayers[i]document);

if (!x && dgetElementById) x=dgetElementById(n);

return x;

}

function showweek() { //显示中文星期

now = new Date() //定义新对象,new具有Date的性质

if (nowgetDay() == 0) return ("星期日")

if (nowgetDay() == 1) return ("星期一")

if (nowgetDay() == 2) return ("星期二")

if (nowgetDay() == 3) return ("星期三")

if (nowgetDay() == 4) return ("星期四")

if (nowgetDay() == 5) return ("星期五")

if (nowgetDay() == 6) return ("星期六")

}

function showdate() { //显示系统日期

var now = new Date()

var year = nowgetYear()

var month = nowgetMonth()+1

var day = nowgetDate()

return year+"年"+month+"月"+day+"日"

}

//documentwrite("<span style='position:absolute; left:40px; top:115px; font-size:10pt; color:#FFFFFF'>"+showdate()+" "+showweek()+"</span>")

//-->

</script>

这里是调用<script>documentwrite("<span color:#000'> 今天是"+showdate()+" "+showweek()+"</span>");</script>

不知道是不是你要的效果

<script type="text/javascript">

//时间日期

$(document)ready(function(){

setInterval(showTime, 1000);

function timer(obj,txt){

objtext(txt);

}

function showTime(){

var today = new Date();

var weekday=new Array(7);

weekday[1]="星期一"

weekday[2]="星期二"

weekday[3]="星期三"

weekday[4]="星期四"

weekday[5]="星期五"

weekday[6]="星期六"

weekday[0]="星期日"

var y=todaygetFullYear()+"年";

var month=todaygetMonth()+1+"月";

var td=todaygetDate()+"日";

var d=weekday[todaygetDay()];

var h=todaygetHours();

var m=todaygetMinutes();

var s=todaygetSeconds();

h=checkTime(h);

m=checkTime(m);

s=checkTime(s);

timer($("#Y"),y);

timer($("#MH"),month);

timer($("#TD"),td);

timer($("#D"),d);

timer($("#H"),h+":");

timer($("#M"),m+":");

timer($("#S"),s);

}

function checkTime(i){

if(i<10){

i="0"+i;

}

return i;

}

})

</script>

<p class="date" style="float:right; margin:5px 10px; text-align:center;">

<strong id="Y"></strong>

<strong id="MH"></strong>

<strong id="TD"></strong>

<strong id="D"></strong><br>

<strong id="H"></strong>

<strong id="M"></strong>

<strong id="S"></strong>

</p>

用定时器,1秒刷一次

以上就是关于在HTML控件中显示本周周一和本周周日的日期全部的内容,包括:在HTML控件中显示本周周一和本周周日的日期、用VBScript代码编写成html形式:1、分别使用select case和if语句判断计算机系统当前日期为星期几。、、如何在html页面中获取系统当前时间等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/9571065.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-04-29
下一篇 2023-04-29

发表评论

登录后才能评论

评论列表(0条)

保存