求教3.9 js中获取当前时间的方法
1个回答
展开全部
<html>
<script type="text/javascript">
window.onload = function()
{
var show = document.getElementById("show");
setInterval(function()
{
var time = new Date();
//程序计时的月从0开始取值后+1
var m = time.getMonth() + 1;
var t = time.getFullYear() + "-" + m + "-" + time.getDate() + " " + time.getHours() + ":" + time.getMinutes() + ":" + time.getSeconds();
show.innerHTML = t;
}, 1000);
};
</script>
<div id="show"></div>
</html>
<script type="text/javascript">
window.onload = function()
{
var show = document.getElementById("show");
setInterval(function()
{
var time = new Date();
//程序计时的月从0开始取值后+1
var m = time.getMonth() + 1;
var t = time.getFullYear() + "-" + m + "-" + time.getDate() + " " + time.getHours() + ":" + time.getMinutes() + ":" + time.getSeconds();
show.innerHTML = t;
}, 1000);
};
</script>
<div id="show"></div>
</html>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询