JS显示日期和时间以及星期
2016-05-08 20:43
676 查看
一下代码显示
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>vvvv</title>
<script type="text/javascript">
var tmpArr = new Array("星期日","星期一","星期二","星期三","星期四","星期五","星期六");
function SetDate()
{
var myDate = new Date();
var temp = myDate.getFullYear() + "年";
temp += (myDate.getMonth() + 1) + "月";
temp += myDate.getDate() + "日";
temp += " " + tmpArr [myDate.getDay()] + " ";
temp += myDate.getHours() + ":";
temp += myDate.getMinutes()+ ":";
temp += myDate.getSeconds();
document.getElementById('div2').innerHTML= temp;
window.setTimeout(SetDate,1000);
};
window.onload = function() {
SetDate();
};
</script>
</head>
<body>
<div id="div2"></div>
</body>
</html>
其实代码简单,纯做记录而已
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>vvvv</title>
<script type="text/javascript">
var tmpArr = new Array("星期日","星期一","星期二","星期三","星期四","星期五","星期六");
function SetDate()
{
var myDate = new Date();
var temp = myDate.getFullYear() + "年";
temp += (myDate.getMonth() + 1) + "月";
temp += myDate.getDate() + "日";
temp += " " + tmpArr [myDate.getDay()] + " ";
temp += myDate.getHours() + ":";
temp += myDate.getMinutes()+ ":";
temp += myDate.getSeconds();
document.getElementById('div2').innerHTML= temp;
window.setTimeout(SetDate,1000);
};
window.onload = function() {
SetDate();
};
</script>
</head>
<body>
<div id="div2"></div>
</body>
</html>
其实代码简单,纯做记录而已
相关文章推荐
- JSON.parse和eval的区别
- jsp笔记
- 使用selenium+phantomjs模拟登录淘宝
- js实现关于数据字典的使用和数据存放的策略
- JSP通过URL跳转到Servlet时乱码解决方案
- JS排序算法
- MVC中JavaScript和CSS的自动打包与压缩
- 关于javascript的原型对象的一些理解
- labjs使用教程
- JS(javascript) delete 详解
- 超详细JSON解析步骤
- Javascript-BOM
- JavaScript获取元素的方式总结
- JS设置cookie,删除cookie
- 使用util.js处理表格
- 使用util.js处理列表
- JavaScript排序算法(希尔排序、快速排序、归并排序)
- JavaScript表达式&运算符
- JavaScript_JavaScript 扩展函数
- JavaScript_在指定节点之后插入新节点_insertAfter(newElement, targetElement) _ JavaScript扩展