Skip to content Skip to sidebar Skip to footer

Convert All Array Object(firestore Timestamp) To Date

I am using firestore and react-native-gifted-chat, I am trying to get all the chat messages from firestore to the chat. However, gifted chat does not support displaying firebase ti

Solution 1:

Sorry for not explore deeply, after checking @Spatz comments I figure out how to do it

documentData.forEach(a => {
  var date = a.createdAt.toDate()
  data.push({
    _id: a._id,
    createdAt: date,
    id: a.id,
    text: a.text,
    user: a.user
  })
})

Solution 2:

Use renderTime prop of gifted chat and pass a function which converts the time and return that time in a string.


Post a Comment for "Convert All Array Object(firestore Timestamp) To Date"