[Vuejs]-How can you retrieve multiple values with momentjs from firebase?

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>
👤ittus

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')
})

Leave a comment