标签:dash tin src cloc char efi clear lang date
<!DOCTYPE html>
<html lang="en">
<head>
<title>Title</title>
<meta charset="UTF-8">
<!--<!– <script src="js_file01.js"></script>–> 尽量放后body前边-->
<style>
#clock{
width: 250px;
}
</style>
</head>
<body>
<input type="text" id="clock">
<input type="button" value="begin" onclick="begin_click()">
<input type="button" value="end" onclick="end()">
<script>
function begin() {
var startTime=getTime();
var ret=document.getElementById("clock");
ret.value=startTime;
}
var ID;
function begin_click() {
// end();
if (ID==undefined){
begin();
ID=setInterval(begin,1000);
}
}
function end() {
clearInterval(ID);
ID=undefined;
}
function getWeek(n) {
week=["星期日","星期一","星期二","星期三","星期四","星期五","星期六"];
return week[n];
}
// alert(week1(2));
function getTime() {
var date_obj=new Date();
var year=date_obj.getFullYear();
var month=date_obj.getMonth()+1;
var day=date_obj.getDate();
var hour=date_obj.getHours();
var minute=date_obj.getMinutes();
var seconds=date_obj.getSeconds();
var week=date_obj.getDay();
return year+"年"+month+"月"+day+"日"+" "+hour+"时"+minute+"分"+seconds+"秒"+" "+getWeek(week)
}
// alert(getTime());
</script>
</body>
</html>
标签:dash tin src cloc char efi clear lang date
原文地址:https://www.cnblogs.com/zxy01/p/13436822.html