我正在尝试使用 https://date-fns.org/ 在 React Native 中格式化我的 Firestore 服务器时间戳
我从文档中找到了这个示例函数
formatDistance(subDays(new Date(), 3), new Date(), { addSuffix: true })
我假设 formatDistance 有两个参数。我计算的日期也是当前日期。 (计算距离)
但是,当使用时:
formatDistance(subDays(new Date(), item.created_at.toDate()), new Date(), { addSuffix: true, })
(item.created_at) - 是我的时间戳。
我收到错误:
Invalid time value
Copyright 2014-2026 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号