Formatting input type date in vue.js
14,394
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.
Comments
-
USER almost 2 years
I use bootstrap-vue.
It includes input type date.
When I write some number, default format is yyyyyy-mm-dd.
I want to change format yyyyyy-mm-dd to yyyy-mm-dd.
-
USER about 5 yearsformatter option works after typing all text. if I type 20190314 it returns 201903-14- .
-
Ohgodwhy about 5 yearsIt should not matter the format at which you type. The purpose of using a data library in the formatter is to take an arbitrary string an attempt to convert it to the proper case. If it's not proper, you should display . an error and let the user know.