使用Jquery动态显示年月日星期时间的代码段

    

        function getDate() {
            var today = new Date();
            var date = today.getFullYear() + "年" + twoDigits(today.getMonth() + 1) + "月" + twoDigits(today.getDate()) + "日 ";
            var week = " 星期" + "日一二三四五六 ".charAt(today.getDay());
            var time = twoDigits(today.getHours()) + ":" + twoDigits(today.getMinutes()) + ":" + twoDigits(today.getSeconds());
            $(".date").html(date + week + time);
        }
        function twoDigits(val) {
            if (val < 10) return "0" + val; return val;
        }
        $(function () {
            setInterval(getDate, 1000);
        });


你可能感兴趣的:(web前端)