Formatting input type date in vue.js

USER picture USER · Mar 14, 2019 · Viewed 8.5k times · Source

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.

Answer

Ohgodwhy picture Ohgodwhy · Mar 14, 2019

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.