博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
JS显示日期时间完整版
阅读量:7038 次
发布时间:2019-06-28

本文共 1388 字,大约阅读时间需要 4 分钟。

<html xmlns=" ">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>当前时间</title>
<script language="javascript">
function tick() {
var hours, minutes, seconds, xfile;
var intHours, intMinutes, intSeconds;
var today, theday;
today = new Date();
function initArray(){
this.length=initArray.arguments.length
for(var i=0;i<this.length;i++)
this[i+1]=initArray.arguments[i] }
var d=new initArray(
"星期日",
"星期一",
"星期二",
"星期三",
"星期四",
"星期五",
"星期六");
theday = today.getYear()+"年" + [today.getMonth()+1]+"月" +today.getDate() +" "+ d[today.getDay()+1];
intHours = today.getHours();
intMinutes = today.getMinutes();
intSeconds = today.getSeconds();
if (intHours == 0) {
hours = "12:";
xfile = "午夜";
} else if (intHours < 12) {
hours = intHours+":";
xfile = "上午";
} else if (intHours == 12) {
hours = "12:";
xfile = "正午";
} else {
intHours = intHours - 12
hours = intHours + ":";
xfile = "下午";
}
if (intMinutes < 10) {
minutes = "0"+intMinutes+":";
} else {
minutes = intMinutes+":";
}
if (intSeconds < 10) {
seconds = "0"+intSeconds+" ";
} else {
seconds = intSeconds+" ";
}
timeString = theday+" "+xfile+" "+hours+minutes+seconds;
Clock.innerHTML = timeString;
window.setTimeout("tick();", 100);
}
window.onload = tick;
</script>
<body>
<div id="Clock" style="font-size:12px"></div>
</body>
</html>

转载于:https://www.cnblogs.com/xgcblog/archive/2011/05/25/2056470.html

你可能感兴趣的文章
关于修改bug的思考
查看>>
国内阿里云Maven镜像(速度飞起)
查看>>
数组的一些操作
查看>>
Microsoft CRM 2013 设置默认组织 default organization
查看>>
【理论基础】ContentProvider的简要概述
查看>>
加快某云下载速度。。。
查看>>
【LeetCode】169 - Majority Element
查看>>
爱上MVC3系列~改变Areas的FindView顺序
查看>>
Where is the warnings view in Android Studio?
查看>>
pycharm中的flask项目如何开启debug模式
查看>>
SpringMVC 利用@ResponseBody注解返回Json时,出现406 not acceptable 错误的解决方法。
查看>>
成为Java GC专家(5)—Java性能调优原则
查看>>
Java TreeMap 源码解析
查看>>
VML+js 完成网页版扫雷
查看>>
如何修改全部DevExpress控件的字体
查看>>
ntp服务器
查看>>
子线程中刷新了UI
查看>>
UIPopoverController事件分发
查看>>
记一次在线安装postgresql-9.4的问题
查看>>
zabbix/自动发现规则
查看>>