为了账号安全,请及时绑定邮箱和手机立即绑定

刚写的代码

<!DOCTYPE html>

<html lang="en">

<head>

<meta charset="UTF-8">

<meta name="viewport" content="width=device-width, initial-scale=1.0">

<meta http-equiv="X-UA-Compatible" content="ie=edge">

<title>Document</title>

<script>

function clock(){

var time='';

var date=new Date();

var year=date.getFullYear();

var month=date.getMonth()+1;

var day=date.getDate();

weekday=["星期日","星期一","星期二","星期三","星期四","星期五","星期六"];

var week=weekday[date.getDay()];

time=date.getHours()+":"+date.getMinutes()+":"+date.getSeconds();

timestamp=year+"年"+month+"月"+day+"日"+week+time;

document.getElementById("atttime").innerHTML=timestamp;

// document.getElementById("atttime2").value=timestamp;

}

setInterval( clock,1000);

</script>

</head>

<body>

<p id="atttime"></p>

<!-- <input type="text" id="atttime2" style="height:50px ;width:400px"> -->

</body>

</html>



正在回答

1 回答

时间间隔小一点,不然可能和本地时间秒数不完全一样

0 回复 有任何疑惑可以回复我~

举报

0/150
提交
取消

刚写的代码

我要回答 关注问题
意见反馈 帮助中心 APP下载
官方微信