js获取当前时间、年月日、星期几
let date = new Date() // 获取时间:时分秒 const hour = date.getHours() < 10 ? "0" + date.getHours() : date.getHours() const minute = date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes() const secound = date.getSeconds() < 10 ? "0" + date.getSeconds() : date.getSeconds() this.datetime = hour + ':' + minute + ':' + secound // 获取日期:年月日 const year = date.getFullYear() const month = date.getMonth() + 1 const day = date.getDate() this.nowDate = month + "月" + day + "日" this.nowYear = year + "年" // 获取星期几 const weeks = new Array("星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"); this.nowWeek = weeks[new Date().getDay()];
废话不多说,直接上代码。
只有及早为自己的前程努力,世界才会早日给你惊喜。只有缩短成功的时日,才能延长生活享受的时间。

 
                
            
         
         浙公网安备 33010602011771号
浙公网安备 33010602011771号