i’m making a blog using firebase, each post is a document created as:
await addDoc(postCollection, {
title,
body,
comments: [
{
userId: "",
content: "",
name: "",
userPhoto: "",
at: "",
},
],
likes: { count: 0, users: [] },
date: new Date().toLocaleDateString(),
createdAt: serverTimestamp(),
user: { name: auth.currentUser.displayName, id: auth.currentUser.uid },
});
I’m not sure how i should use moment( ).fromNow( ), but i created the property “at” to register the time i make a comment. Each time i make a comment i pass moment( ).format( ) to the “at” propert.
At the comment section, i have the following span
<span>{moment(item.at).fromNow()}</span>
But it keeps showing that i made the comment “A few seconds ago”. How should i use it to work properly?
Thanks in advance
