获取当前浏览器的当前时间,包括时、分、秒(可用作倒计时)

技术文章 无标签 2018-08-17
/*获取当前日期信息*/
        getDayTime: function () {
            var d = new Date();
            var year = d.getFullYear();
            var month = d.getMonth() + 1;
            var date = d.getDate();
            var day = d.getDay();
            var h = d.getHours();
            var m = d.getMinutes();
            var s = d.getSeconds();
            if (h < 10) { h = "0" + h; }
            if (m < 10) { m = "0" + m; }
            if (s < 10) { s = "0" + s; }
            var week = ["日", "一", "二", "三", "四", "五", "六"];
            //var str = year + "年" + month + "月" + date + "日&nbsp;星期" + week[day] + "&nbsp;" + h + ":" + m + ":" + s;
            return str;
        }

0条评论