如何将Solana块时间转换为正常时间?

发布于 2025-01-26 02:45:55 字数 420 浏览 3 评论 0原文

我正在使用solana api,并且由于一个函数,我得到了这样的响应:

{
  blockTime: 1646251782,
  confirmationStatus: 'finalized',
  err: null,
  memo: null,
  signature: 'xyz',
  slot: 123192670
}

如您所见,有blocktime字段,我想从中提取值。当我使用MONK进行此操作时:

console.log(moment(1646251782).toISOString())

我有1970年,但这是不正确的,我在Solana Explorer上检查了一下,并且有正常的时间。我如何获得正常约会或我做错了什么?

I'm using solana API and as a result of one function I get such response:

{
  blockTime: 1646251782,
  confirmationStatus: 'finalized',
  err: null,
  memo: null,
  signature: 'xyz',
  slot: 123192670
}

As you can see, there is blockTime field, and I want to extract value from it. When I was doing it with moment:

console.log(moment(1646251782).toISOString())

I got 1970 year, but it's incorrect, and I check this on solana explorer, and there was normal time. How can I get normal date or what do I do wrong?

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

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

发布评论

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

评论(1

雪落纷纷 2025-02-02 02:45:55

这是unix以毫秒为单位的时间,使用时刻您可以使用以下时间提取时间:

moment.unix(1650493606).format("YYYY-MM-DD HH:mm:ss")

This is unix time in milliseconds, using moment you can extract time using this:

moment.unix(1650493606).format("YYYY-MM-DD HH:mm:ss")
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文