html获取系统时间 5
展开全部
用html语言来获取确实有点难度,这是用JS来做的放在文件里面可以在标题栏显示时间。
<SCRIPT LANGUAGE="JavaScript">
var clocktext;
var pagetitle = document.title;
function scroll() {
today = new Date();
sec = today.getSeconds();
hr = today.getHours();
min = today.getMinutes();
if (hr <= 9) hr = "0" + hr;
if (min <= 9) min = "0" + min;
if (sec <= 9) sec = "0" + sec;
var clocktext = " 现在时间是: " + hr + ":" + min + ":" + sec;
clocktimer = setTimeout("scroll()", 1000);
document.title = pagetitle + clocktext;
}
if (document.all) scroll();
</script>
<SCRIPT LANGUAGE="JavaScript">
var clocktext;
var pagetitle = document.title;
function scroll() {
today = new Date();
sec = today.getSeconds();
hr = today.getHours();
min = today.getMinutes();
if (hr <= 9) hr = "0" + hr;
if (min <= 9) min = "0" + min;
if (sec <= 9) sec = "0" + sec;
var clocktext = " 现在时间是: " + hr + ":" + min + ":" + sec;
clocktimer = setTimeout("scroll()", 1000);
document.title = pagetitle + clocktext;
}
if (document.all) scroll();
</script>
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
<body>
<script type="text/javascript">
var today = new Date(); //新建一个Date对象
var date = today.getDate();//查询当月日期
var day = today.getDay();//查询当前星期几
var month = today.getMonth();//查询月份
var year = today.getFullYear();//查询年份
document.write(year+"-"+month+"-"+date+"<br />");
</script>
</body>
<script type="text/javascript">
var today = new Date(); //新建一个Date对象
var date = today.getDate();//查询当月日期
var day = today.getDay();//查询当前星期几
var month = today.getMonth();//查询月份
var year = today.getFullYear();//查询年份
document.write(year+"-"+month+"-"+date+"<br />");
</script>
</body>
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2017-07-26
展开全部
var myDate = new Date();//获取系统当前时间
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询