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

获取当前系统时间-月日时分周

时间:2015-10-08 16:33:49      阅读:148      评论:0      收藏:0      [点我收藏+]

标签:

1.显示结果;

技术分享

2,样式;

<style>
.top_time{ float:right; width:240px; color:#0026ff;text-shadow:3px 3px 5px #6388c2; font-size:16px; padding-top:10px;}
.top_time #time{ font-size:48px; float:left; height:50px; line-height:50px; padding-right:15px;}
.top_time #date{ padding-top:10px;}
</style>

3,js

 1  <div class="top_time top_time_r">
 2         <div id="time"></div>
 3         <div id="date"></div>
 4         <div id="week"></div>
 5         <script>
 6             setInterval("setDate()", 1000);
 7             function setDate() {
 8                 var myDate = new Date();
 9                 var hours = myDate.getHours();
10                 var date = myDate.getMinutes();
11                 var month = myDate.getMonth();
12                 var date1 = myDate.getDate();
13                 if (myDate.getHours() < 10)
14                     hours = "0" + myDate.getHours();
15                 if (myDate.getMinutes() < 10)
16                     date = "0" + myDate.getMinutes();
17                 if (myDate.getMonth() < 9) {
18                     //  alert(myDate.getMonth());
19                     month = "0" + (parseInt(myDate.getMonth()) + 1);
20                 } else {
21                     month =parseInt(myDate.getMonth()) + 1;
22                 }
23                  
24                 if (myDate.getDate() < 10)
25                     date1 = "0" + myDate.getDate();
26                 document.getElementById("time").innerHTML = hours + ":" + date;
27                 document.getElementById("date").innerHTML = month + "-" + date1;
28                 document.getElementById("week").innerHTML = 星期 + 日一二三四五六.charAt(new Date().getDay());
29             }
30         </script>
31     </div>

 

获取当前系统时间-月日时分周

标签:

原文地址:http://www.cnblogs.com/lindaguoflh/p/4861191.html

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