js 展示当前时间
setNowTimes: function () {
var myDate = new Date(); // console.log(myDate) var wk = myDate.getDay(); var yy = String(myDate.getFullYear()); var mm = myDate.getMonth()+1; mm = String(mm < 10 ? '0' + mm : mm); var dd = String(myDate.getDate() < 10 ? '0' + myDate.getDate() : myDate.getDate()); var hou = String(myDate.getHours() < 10 ? '0' + myDate.getHours() : myDate.getHours()); var min = String(myDate.getMinutes() < 10 ? '0' + myDate.getMinutes() : myDate.getMinutes()); var sec = String(myDate.getSeconds() < 10 ? '0' + myDate.getSeconds() : myDate.getSeconds()); var weeks = ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六']; var week = weeks[wk]; this.nowDate = yy + '-' + mm + '-' + dd; this.nowTime = hou + ':' + min + ':' + sec; this.nowWeek = week; }