js date时间eg


var D = {
        version:"1.0.1",
        
        date:function(){
            d = new Date();
            return d;
        },
        
        getYear:function(){
            return this.date().getFullYear();
        },
        
        getMonthOfYear:function(){
            return this.date().getMonth()+1;
        },
        
        getDayOfMonth:function(){
            return this.date().getDate();
        },
        
        getDayOfWeek:function(){
            dayOfWeek = this.date().getDay();
            return this.formatXq(dayOfWeek);
        },
        
        getHour:function(){
            return this.date().getHours();
        },
        
        getMinute:function(){
            return this.date().getMinutes();
        },
        
        getSecond:function(){
            return this.date().getSeconds();
        },
        
        getMilliSecond:function(){
            return this.date().getMilliseconds();
        },
        
        formatXq:function(dayOfWeek){
                switch(dayOfWeek)
                {
                    case 0:
                        dayOfWeek = "星期天";
                        break;
                    case 1:
                        dayOfWeek = "星期一";
                        break;
                    case 2:
                        dayOfWeek = "星期二";
                        break;
                    case 3:
                        dayOfWeek = "星期三";
                        break;
                    case 4:
                        dayOfWeek = "星期四";
                        break;
                    case 5:
                        dayOfWeek = "星期五";
                        break;
                    case 6:
                        dayOfWeek = "星期六";
                        break;
                }
                return dayOfWeek;
        }
}

function setTime()
{
    jQuery("#year").html(D.getYear());
    jQuery("#month").html(D.getMonthOfYear());
    jQuery("#day").html(D.getDayOfMonth());
    
    jQuery("#hour").html(D.getHour());
    jQuery("#minute").html(D.getMinute());
    jQuery("#second").html(D.getSecond());
    jQuery("#xq").html(D.getDayOfWeek());
}

function setMilliSecond()
{
    jQuery("#millisecond").html(D.getMilliSecond());
}

window.setInterval(setTime, 1000);
window.setInterval(setMilliSecond, 0.1);


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值