I'm trying to convert a datetime result to date using split. But as much as it shows the date correctly without the time, it doesn't display in the input.
data(){
return {
date_created: String(this.date_created).split('T')[0],
},
},
methods: {
editItem (item) {
this.date_created = item.society_date_created
this.dialog = true
},
},
created: function(){
axios.get(process.env.VUE_APP_Back "/societies")
.then(response => {
this.society = response.data;
})
.catch(error => {
this.society = error.data;
});
this.loadTable= false;
},
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script>
<input type="date" v-model="date_created" disabled>
Reponse date_created in api
2020-06-30T00:00:00.000Z
CodePudding user response:
You need to set this.date_created in your editItem method
data(){
return {
date_created: null
},
},
methods: {
editItem (item) {
this.date_created = item.society_date_created.split('T')[0]
this.dialog = true
},
},