日期时间

 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 }

 

posted @ 2015-08-19 10:55  alon_web  阅读(260)  评论(0编辑  收藏  举报