码迷,mamicode.com
首页 > 其他好文 > 详细

基础 - 日期 Date

时间:2016-08-07 23:04:57      阅读:213      评论:0      收藏:0      [点我收藏+]

标签:

样式

<div id="showDate" class="box">
<p>1970-1-1 8:00 星期鬼</p>
<span>1</span>
</div>

结构

* {
margin: 0;
padding: 0;
}
.box {
width: 500px;
padding: 10px;
margin: 100px auto;
text-align: center;
font: 400 18px/20px "SimSun","\5b8b\4f53";
font-weight:bold;">#DBE1E7;
}
.box p {
font-weight:bold;">#666666;
}
.box span{
display: block;
width: 40px;
height: 40px;
line-height: 40px;
margin: 10px auto;
font-weight:bold;">#C81623;
}

行为

window.onload = function () {

function funXingQi(oDate) {
switch (oDate.getDay()) {
case 0: return "星期日";
case 1: return "星期一";
case 2: return "星期二";
case 3: return "星期三";
case 4: return "星期四";
case 5: return "星期五";
case 6: return "星期六";
}
}

var oDate = new Date();
/**/
var nFullYear = oDate.getFullYear();
/**/
var nMonth = oDate.getMonth()+1;
/**/
var nDate = oDate.getDate();
/**/
var nHours = oDate.getHours();
/**/
var nMinutes = oDate.getMinutes();
/**/
var nSeconds = oDate.getSeconds();
/*刹那*/
var nMilliseconds = oDate.getMilliseconds();
/*时间戳*/
var nTime = oDate.getTime();
var nValueOf = oDate.valueOf();

var oShowDate = document.getElementById("showDate");
var oShowP = oShowDate.getElementsByTagName("p")[0];
var oShowSpan = oShowDate.getElementsByTagName("span")[0];

oShowP.innerHTML = funXingQi(oDate)+" "+ nFullYear+""+nMonth+"月"+nDate+"日"+nHours+"时"+nMinutes+"分"+nSeconds+"秒"+nMilliseconds;
  oShowSpan.innerHTML = nDate;


}

 

基础 - 日期 Date

标签:

原文地址:http://www.cnblogs.com/WeWeZhang/p/5747495.html

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