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.
In the example below we are using vue so therefore we create a method called formatDate() and pass in the date that we want to format. We then set our options of how we want the date to be shown. This is an object where we can choose if we want the month to be numeric or long for example.
To set and get the input type date in dd-mm-yyyy format we will use <input> type attribute. The <input> type attribute is used to define a date picker or control field. In this attribute, you can set the range from which day-month-year to which day-month-year date can be selected from.
The <input type="date"> defines a date picker. The resulting value includes the year, month, and day.
Vue uses an HTML-based template syntax that allows you to declaratively bind the rendered DOM to the underlying component instance's data. All Vue templates are syntactically valid HTML that can be parsed by spec-compliant browsers and HTML parsers.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With