I am currently working on a Vue component that includes an input field with a date type:
<input
type="date"
name="start_date"
id="start_date"
v-model="absence.start_date"
>
Within my script, I am attempting to format the date for proper display:
<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>
Unfortunately, the format from the API response is causing issues.
When I manually set the date, it works with this format:
start_date: '2021-01-01',
However, it gets overridden by the data from the API call. I have Moment.js installed in app.js, how can I utilize it to format the date from the API response?
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}}