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('今天是 <span class="red">'+year+'年'+month+'月'+day+'号 星期'+xq+'</span> '+hour+' '+hours+':'+minutes+':'+seconds);
29 }
30 setInterval(show,1000);
31 });
32 }