码迷,mamicode.com
首页 > Windows程序 > 详细

js_window_date

时间:2020-08-05 00:08:13      阅读:96      评论:0      收藏:0      [点我收藏+]

标签:dash   tin   src   cloc   char   efi   clear   lang   date   

<!DOCTYPE html>
<html lang="en">
<head>
<title>Title</title>
<meta charset="UTF-8">
<!--&lt;!&ndash; <script src="js_file01.js"></script>&ndash;&gt; 尽量放后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>

js_window_date

标签:dash   tin   src   cloc   char   efi   clear   lang   date   

原文地址:https://www.cnblogs.com/zxy01/p/13436822.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!