vue 获取当前时间年月日 时分秒

 created() { 
   this.setTimes();
 },
 
 methods: {
  setTimes() {
   var _this = this;
   let yy = new Date().getFullYear();
   let mm = new Date().getMonth() + 1;
   let dd = new Date().getDate();
   let hh = new Date().getHours();
   let mf = new Date().getMinutes() < 10 ? "0" + new Date().getMinutes() : new Date().getMinutes();
   let ss = new Date().getSeconds() < 10 ? "0" + new Date().getSeconds() : new Date().getSeconds();
   _this.form.startTime = yy + "-" + mm + "-" + dd + " " + hh + ":" + mf + ":" + ss;
   }
 }

你可能感兴趣的:(vue2.0,vue.js,javascript,ecmascript)