码迷,mamicode.com
首页 > Web开发 > 详细

js当前时间

时间:2015-06-11 18:21:22      阅读:181      评论:0      收藏:0      [点我收藏+]

标签:

<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
<script type="text/javascript">
function initArray() {
	for (i = 0; i < initArray.arguments.length; i++)
		this[i] = initArray.arguments[i];
}
var isnMonths = new initArray("1月", "2月", "3月", "4月", "5月", "6月", "7月", "8月", "9月", "10月", "11月", "12月");
var isnDays = new initArray("星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六", "星期日");
today = new Date();
hrs = today.getHours();
min = today.getMinutes();
sec = today.getSeconds();
clckh = "" + ((hrs > 12) ? hrs - 12 : hrs);
clckm = ((min < 10) ? "0" : "") + min;
clcks = ((sec < 10) ? "0" : "") + sec;
clck = (hrs >= 12) ? "下午" : "上午";
var stnr = "";
var ns = "0123456789";
var a = "";

function getFullYear(d) {
	yr = d.getYear();
	if (yr < 1000)
		yr += 1900;
	return yr;
}

document.write(getFullYear(today) + "年" + isnMonths[today.getMonth()] + today.getDate() + "日" + " " + clck+" "+clckh + ":" + clckm + ":" + clcks + " " +  isnDays[today.getDay()]);
</script>
</head>
<body>
	
</body>
</html>

  

js当前时间

标签:

原文地址:http://www.cnblogs.com/JAYIT/p/4569332.html

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