Reputation: 781
I use bootstrap-vue, which includes an input type of date.
When I write some number, the default format is yyyyyy-mm-dd.
I want to change that format to yyyy-mm-dd.
Upvotes: 7
Views: 25784
Reputation: 24488
I am using moment.js
data:{
startDate: moment().format("YYYY-MM-DD"),
endDate: moment().format("YYYY-MM-DD"),
}
HTML
<input type="date" class="form-control" v-model="startDate"> {{startDate}}
<input type="date" class="form-control" v-model="endDate"> {{endDate}}
Upvotes: 2
Reputation: 1
Try this :
<input type="date" v-model="moment(mydate).format('YYYY-MM-DD')" v-on:input="mydate = moment($event.target.value).toDate()"/>
Upvotes: -1
Reputation: 50798
use a formatter:
:formatter="format"
Declare how the value should be formatted within this function:
format(value, event) {
return moment(value).format('YYYY-MM-DD')
}
As an example using the momentjs
library.
Upvotes: 11