复制代码 代码如下:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript">
function bodyLoad(){
var dateTime=new Date();
var hh=dateTime.getHours();
if(hh<10) hh = '0' + hh;
var mm=dateTime.getMinutes();
if(mm<10) mm = '0' + mm;
var ss=dateTime.getSeconds();
if(ss<10) ss = '0' + ss;
var yy=dateTime.getFullYear();
var MM=dateTime.getMonth()+1; //因为1月这个方法返回为0,所以加1
var dd=dateTime.getDate();
var week=dateTime.getDay();
var days=[ "日 ", "一 ", "二 ", "三 ", "四 ", "五 ", "六 ",]
document.getElementById("date").value=yy+"年"+MM+"月"+dd+"日 "+"星期"+days[week] ;
document.getElementById("time").value=hh+":"+mm+":"+ss;
setTimeout(bodyLoad,1000);
}
</script>
</head>
<body onload="bodyLoad()">
<input type="text" id="date" style="border:0 none;" /><input type="text" id="time" style="border:0 none;" />
</body>
</html>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript">
function bodyLoad(){
var dateTime=new Date();
var hh=dateTime.getHours();
if(hh<10) hh = '0' + hh;
var mm=dateTime.getMinutes();
if(mm<10) mm = '0' + mm;
var ss=dateTime.getSeconds();
if(ss<10) ss = '0' + ss;
var yy=dateTime.getFullYear();
var MM=dateTime.getMonth()+1; //因为1月这个方法返回为0,所以加1
var dd=dateTime.getDate();
var week=dateTime.getDay();
var days=[ "日 ", "一 ", "二 ", "三 ", "四 ", "五 ", "六 ",]
document.getElementById("date").value=yy+"年"+MM+"月"+dd+"日 "+"星期"+days[week] ;
document.getElementById("time").value=hh+":"+mm+":"+ss;
setTimeout(bodyLoad,1000);
}
</script>
</head>
<body onload="bodyLoad()">
<input type="text" id="date" style="border:0 none;" /><input type="text" id="time" style="border:0 none;" />
</body>
</html>
标签:
当前日期,网页,头部
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件!
如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
桃源资源网 Design By www.nqtax.com
暂无“js获取当前日期代码适用于网页头部”评论...