如何在JSP页面中显示当前时间
展开全部
JS内容
<script type="text/javascript">
var weeks=["日","一","二","三","四","五","六"];
function showTime(){
var date=new Date();
var y=date.getFullYear();
var m=date.getMonth()+1;
var d=date.getDate();
var w=date.getDay();
var h=date.getHours();
var mi=date.getMinutes();
var s=date.getSeconds();
var ms=m<10?"0"+m:m;
var ds=d<10?"0"+d:d;
var hs=h<10?"0"+h:h;
var mis=mi<10?"0"+mi:mi;
var ss=s<10?"0"+s:s;
var time=y+"年"+ms+"月"+ds+"日 "+hs+":"+mis+":"+ss+" 星期"+weeks[w];
document.getElementById("div_time").innerHTML=time;
setTimeout("showTime()",1000);
}
</script>
jsp页面内容
<div id="div_time" align="right"></div>
<script type="text/javascript">
var weeks=["日","一","二","三","四","五","六"];
function showTime(){
var date=new Date();
var y=date.getFullYear();
var m=date.getMonth()+1;
var d=date.getDate();
var w=date.getDay();
var h=date.getHours();
var mi=date.getMinutes();
var s=date.getSeconds();
var ms=m<10?"0"+m:m;
var ds=d<10?"0"+d:d;
var hs=h<10?"0"+h:h;
var mis=mi<10?"0"+mi:mi;
var ss=s<10?"0"+s:s;
var time=y+"年"+ms+"月"+ds+"日 "+hs+":"+mis+":"+ss+" 星期"+weeks[w];
document.getElementById("div_time").innerHTML=time;
setTimeout("showTime()",1000);
}
</script>
jsp页面内容
<div id="div_time" align="right"></div>
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询