Article From:https://segmentfault.com/q/1010000011711692
Question:

elementUIThe datepicker is used to show the data. Is there a way to convert the long-type data frame from the interface directly into a time format? Does the document look for something that doesn’t seem to exist? Is there any better way to convert it?

Answer 0:

formatProperty can only change the format of the display date, but ultimately get the same UTC time type, you can get the data to do a transformation:
(1)UTCTime to xxxx-xx-xx format

 dateChange: function () {
     var time = this.deliveryDate;//Get current date space timeIf (time) {Var date = new Date (Date.parse (time));Var newDate = date.getFUllYear () + "-" + (date.getMonth (+) + 1 < 10'0'+ (date.getMonth () + 1): (date.getMonth () + 1)+ "-" + (date.getDate () < 10?'0'+ date.getDate (): date.getDate ();Return newDate;}},

(2)If time is to be displayed, you must use the UTC value to assign, otherwise the ele date control may not be available.

getUTCTime: function (str) {
   var str = new Date(str);
   var utc = str.toUTCString();
       return utc;
}

Answer 1:

Directly use new Date () to turn the time stamp directly into time.

Answer 2:
<el-date-picker
  v-model="birthday"
  type="date"
  placeholder="Please choose birthday.Picker-options= "pickerOptions0"Size= "small"@change= "getTime">< /el-date-picKer>

methods inside

getTime(date){
  this.birthday=date;
  console.log(this.birthday);
}

The perfect solution is to adopt the date format after obtaining 2017-10-25.

Answer 3:

It is wrong to report back.
It’s simple.
Write a computed method:

_release_time: {
  get() {
    return this.form.release_time.toString();
  },
  set(val) {
    this.form.release_time = val;
  },
},

When used:

<el-date-picker
  v-model="_release_time"
  type="date"
  size="small"
  format="yyyy-MM-dd"
  value-format="yyyyMMdd"
  placeholder="Select the date ">";< /el-date-picker>

Similar Posts:

Leave a Reply

Your email address will not be published. Required fields are marked *