Friday, May 17, 2024
 Popular · Latest · Hot · Upcoming
27
rated 0 times [  29] [ 2]  / answers: 1 / hits: 6653  / 4 Years ago, tue, july 28, 2020, 12:00:00

I'am trying to get a proper output of date from the v-calendar. Now this looks like:


Fri Jul 31 2020 00:00:00 GMT+0200 (utc summertime) 

This should be 2020-07-28 etc.. I Can't find anything in the documentation that work, anyone know how to change output?


Code:



{{ date }}

<v-date-picker
v-model="date"
color="red"
is-inline
:available-dates='dates'
:masks='{ input:["L", "YYYY-MM-DD"] }'
/>


Script for test:


<script>
var app = new Vue({
el: "#dic",
data: {
date: moment().format('YYYY-MM-DD'),
},
});
</script>

More From » vue.js

 Answers
0

Add a computed property called formattedDate based on date and use it and keep the data property :




let app = new Vue({
el: '#app',
data: {
date: moment().format('YYYY-MM-DD'),
},

computed: {
formattedDate() {
return moment(this.date).format('YYYY-MM-DD')
}
}
})

<script src='https://unpkg.com/vue/dist/vue.js'></script>

<script src='https://momentjs.com/downloads/moment.min.js'></script>
<script src='https://unpkg.com/v-calendar'></script>
<div id='app'>
{{formattedDate }}

<v-date-picker v-model=date color=red is-inline />
</div>




[#3046] Saturday, July 25, 2020, 4 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
taylert

Total Points: 627
Total Questions: 91
Total Answers: 108

Location: Mayotte
Member since Mon, Sep 12, 2022
2 Years ago
taylert questions
;