本文主要是介绍获取当前浏览器的当前时间,包括时、分、秒(可用作倒计时),希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
/*获取当前日期信息*/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 + "日 星期" + week[day] + " " + h + ":" + m + ":" + s;return str;}
这篇关于获取当前浏览器的当前时间,包括时、分、秒(可用作倒计时)的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!