我尝试使用 moment 显示我从 Firestore 发布的帖子选择的事件日期。现在它只打印当天,所以我显示日期但不是正确的方式。我没有收到错误消息。我试图将时间戳更改为“dateUpload”。但它在我的文本组件中打印了“无效日期”。有没有人知道我能做什么?
这就是我的平面列表显示它的方式:
postDate={moment(item.timestamp).format("ll")}
在我的 redux Action.js
export function fetchFollowingUsersPosts(uid) {
return ((dispatch, getState) => {
firebase.firestore()
.collection("posts")
.doc(uid)
.collection("userPosts")
.orderBy("creation", "asc")
.get()
.then((snapshot) => {
const uid = snapshot.query.EP.path.segments[1];
const user = getState().usersState.users.find(el => el.uid === uid);
const posts = snapshot.docs.map((doc) => {
const { data: firebaseTimestamp, ...rest } = doc.data()
const id = doc.id;
const data = firebaseTimestamp ? moment(firebaseTimestamp.toDate()) : null
return {
...rest,
id,
user,
...data
}
})
//console.log(posts);
dispatch({ type: USERS_POSTS_STATE_CHANGE, posts, uid, })
})
})
}
我的数据库上的图像: