Get timezone difference in hours with moment(以小时为单位获取时区差异)
问题描述
我想通过 Node.js moment 模块获取纽约和香港之间的时区差异.我已经做了一些前期工作.
I would like to get the timezone difference between New York and Hong Kong with Node.js moment module. I have done some preliminary work.
然后我可以继续编写一个函数来计算两个时区之间的时间差(以小时为单位).我希望有一个更简单的方法.
I can then proceed to write a function to calculate the difference between the 2 timezones in hours. I was hoping for a simpler method.
有没有更优雅、更简单的方式来使用矩库?
Is there a more elegant and simpler way to do it with moment library?
推荐答案
不确定更简单",但更正确(因为并非所有时区都相隔一小时):
Not sure about "simpler", but more correct (since not all timezones are a full hour from each other):
这篇关于以小时为单位获取时区差异的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!