1👍
This is a nice case to use Vue filter
<template>
<div v-for="data in array">
{{ data | formatTime }}
</div>
</template>
<script>
import moment from 'moment'
export default{
data(){
return{
array: []//example:1577200868199, 1577200868189,...
}
},
filters: {
formatTime: function (value) {
return moment(value).format('MMMM Do YYYY, h:mm:ss a')
}
}
}
</script>
- [Vuejs]-Code attached to watch: {} never executes although the watched variable does indeed change
- [Vuejs]-No pics or api while generating Nuxt static page
0👍
With moment you can only parse one item at a time, so you can change your code to loop over your array and parse each item individually. It would look something like this.
this.array.forReach(posted_at => {
moment(posted_at).format('MMMM Do YYYY, h:mm:ss a')
})
- [Vuejs]-How to set date range for date of birth and date of death in vue.js datepicker?
- [Vuejs]-Call a json from a list when loading page in Vue
Source:stackexchange.com