momentjs

How to use moment.js to get remaining hours, minutes, and seconds from a unix timestamp?

有些话、适合烂在心里 提交于 2020-11-29 10:59:07
问题 Given a unix timstamp in the future, how can I use Moment.js to get the hours, minutes, and seconds remaining until then? For example: now = 1589252712837 time = 1589356202907 // This is the line I do not know res = moment(time - now) console.log(res) // 23 hours, 12 minutes, 3 seconds Edit: I believe I can do something like this, but is there a native way to do it?: now = 1589252712837 time = 1589356202907 remaining = time - now hour = moment(remaining).hour() minute = moment(remaining)

Get UTC offset from timezone abbreviations

眉间皱痕 提交于 2020-11-25 03:57:03
问题 Is there anyway to get utc offset from a timezone abbreviations? Such as: "PST" for Pacific Standard Time (North America) which will result in UTC−08 . I found a way on moment-timezone but it did not help much. It provides a list of timezone identifier but most of them are deprecated. Thank you. 回答1: This is a quite tricky topic and similar questions have already been discussed. See Detect timezone abbreviation using JavaScript or Get timezone abbreviation using offset value I would propose