将时间戳转换为firebase的字符串

发布于 2025-02-10 02:37:43 字数 194 浏览 1 评论 0原文

在此处输入映像我从firestamp访问了firestamp,并将其打印为字符串,但没有显示出来,但它没有显示以日期格式!我无法在不将其转换为字符串中,也无法将其从Fromat转换为字符串。

enter image description hereI accessed the timestamp from firestore and printed it as an string but it's not showing in date format! I'm not being able to print timestamp inside Text widget without converting it into string fromat either.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

萌辣 2025-02-17 02:37:43

如果您不想使用Firestore功能,那么将时间戳转换为JavaScript日期或您所说的字符串就是这样的最简单方法:

new Date(timestamp.seconds * 1000).toLocaleDateString()

时间戳是具有秒和纳秒的对象,您可以创建一个日期实例,请通过时间戳秒,并用1000乘。现在您可以根据需要将其格式化。

If you don't want to use Firestore function, than the easiest way to convert a timestamp to a JavaScript date or as you said string is like this:

new Date(timestamp.seconds * 1000).toLocaleDateString()

The timestamp is an object with seconds and nanoseconds, you create an date instance, pass the timestamp seconds and multiply with 1000. Now you can format this as you want.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文