Date picker returning dateTime with time zone in VueJS Element Library
I'm using date picker from http://element.eleme.io/#/en-US/component/date-picker
It should return date in form:
yyyy-MM-dd
However, it is returning like:
Thu Apr 20 2017 00:00:00 GMT+0530 (India Standard Time)
This is the code that I've used
<el-date-picker
v-model="date"
type="date"
placeholder="Pick a day"
format="yyyy-MM-dd">
</el-date-picker>
You can use computed property
or filter
to get the desired output.
Example: https://jsfiddle.net/wostex/63t082p2/33/
<div id="app">
<el-date-picker
v-model="date"
type="date"
placeholder="Pick a day"
format="yyyy-MM-dd">
</el-date-picker>
<p v-if="date">{{ dateFormat }}</p>
</div>
new Vue({
el: '#app',
data: {
date: null
},
computed: {
dateFormat: function() {
let date = new Date(this.date);
return date.getFullYear() + '-' +
(date.getMonth() +1) + '-' +
date.getDate();
}
}
});
链接地址: http://www.djcxy.com/p/46592.html
上一篇: 使用UTC时区将毫秒转换为UTC日期对象