jQuery 中时间显示的模版

来源:互联网 发布:软件系统测试报告 编辑:程序博客网 时间:2024/06/07 05:48
function setTime() {
                var time = new Date();
                var year = time.getFullYear();
                var month = time.getMonth() + 1;
                var day = time.getDate();
                var hour = time.getHours();
                var minute = time.getMinutes();
                var second = time.getSeconds();
                var weekDay;
                if (minute<10) {
                    hour ='0'+hour;
                }
                if (second<10) {
                    second = '0'+second;
                }
                if(time.getDay() == 0) {
                    weekDay = "星期日 "
                }
                if(time.getDay() == 1) {
                    weekDay = "星期一 "
                }
                if(time.getDay() == 2) {
                    weekDay = "星期二 "
                }
                if(time.getDay() == 3) {
                    weekDay = "星期三 "
                }
                if(time.getDay() == 4) {
                    weekDay = "星期四 "
                }
                if(time.getDay() == 5) {
                    weekDay = "星期五 "
                }
                if(time.getDay() == 6) {
                    weekDay = "星期六 "
                }
                var timeFinal = year + "年" + month + "月" + day + "日" + weekDay + hour + ":" + minute + ":" + second;
                return timeFinal;
            }
                        setInterval(function show(){
                            $('#times').text(setTime())
                        }) 

        })

0 0
原创粉丝点击