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

日期时间

时间:2015-08-19 12:37:16      阅读:141      评论:0      收藏:0      [点我收藏+]

标签:

 1 /**
 2 * 日期时间
 3 */
 4 $.fn.topbarTime = function(opt){
 5     this.each(function(){
 6         var $me = $(this);
 7         var show = function(){
 8             var date = new Date(),
 9             year = date.getFullYear(),
10             month = date.getMonth()+1,
11             day  = date.getDate(),
12             hours = date.getHours(),
13             minutes = date.getMinutes(),
14             seconds = date.getSeconds(),
15             xq = ‘日一二三四五六‘.charAt(date.getDay())
16             hour =‘‘;
17             if(hours >=0 && hours <= 6){
18                 hour =‘凌晨‘
19             }else if(hours > 6 && hours <= 12){
20                 hour =‘上午‘
21             }else if(hours >= 12 && hours < 14){
22                 hour =‘中午‘
23             }else if(hours >= 14 && hours < 19){
24                 hour =‘下午‘
25             }else if(hours >= 19 && hours < 23){
26                 hour =‘晚上‘
27             }
28             $me.html(‘今天是&nbsp;&nbsp;<span class="red">‘+year+‘年‘+month+‘月‘+day+‘号&nbsp;&nbsp;星期‘+xq+‘</span>&nbsp;&nbsp;‘+hour+‘&nbsp;&nbsp;‘+hours+‘:‘+minutes+‘:‘+seconds);
29         }
30         setInterval(show,1000);
31     });
32 }

 

日期时间

标签:

原文地址:http://www.cnblogs.com/fflong/p/4741597.html

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