I have a Vue component with an input field which is a date type:
<input
type="date"
name="start_date"
id="start_date"
v-model="absence.start_date"
>
In my script I am trying to format the date so that it displays correctly:
<script>
export default {
data() {
return {
absence: {
start_date: null,
}
}
},
created() {
const request = axios
.get(`/api/absences/${this.$route.params.id}`)
.then(response => {
this.absence = response.data.data;
});
}
}
</script>
However it doesn't work with the format returned by the API.
If I set the date manually it works in this format
start_date: '2021-01-01',
However it is overwritten by the api call. I have moment installed in app.js, how can I use moment to format the date returned by the api call?
EDIT
This is the API response:
{"success":true,"data":{"id":1,"start_date":"2021-07-24 00:00:00","end_date":"2021-07-25 00:00:00","notes":"Quis nisi repellendus ipsa. Eum asperiores sunt iusto exercitationem autem. Qui harum adipisci praesentium laboriosam. Fugit quasi voluptatem excepturi et non autem atque quibusdam. Sed aperiam molestias quaerat incidunt.","created_at":"2021-06-28T19:34:16.000000Z","updated_at":"2021-07-03T15:46:10.000000Z","status":1}}