Momentjs时间正在返回出乎意料的结果
我试图显示澳大利亚的时间(UTC +11 偏移量,39600 秒), 但由于某种原因,每当我用 moment.unix().format() 运算符显示时间时,时间就会减少几个小时。
const moment = require('moment');
const timestamp = moment().unix()
const australia_offset = 39600
console.log(`${moment.unix(timestamp + australia_offset).format('hh:mm a')} | ${timestamp} | ${australia_offset}`);
有谁知道为什么会发生这种情况以及我该如何解决它?一段时间以来,我一直试图自己解决这个问题,但我似乎无法弄清楚我做错了什么。
笔记: 当我尝试通过另一个转换器运行数据时,它会以正确的时间显示,因此我 100% 确定添加没有错误。
I'm attempting to have the time of Australia display (UTC +11 offset, 39600 in seconds),
but for some reason whenever I go to display the time with the moment.unix().format() operator, the time is hours off.
const moment = require('moment');
const timestamp = moment().unix()
const australia_offset = 39600
console.log(`${moment.unix(timestamp + australia_offset).format('hh:mm a')} | ${timestamp} | ${australia_offset}`);
Does anybody have any clue why this is happening and how I could fix it? I've been trying to figure this out myself for a while and I can't seem to figure out what I'm doing wrong.
Note:
When I attempt to run the data through another converter, it shows up with the proper time, so I'm 100% sure the addition isn't wrong.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论