moment-timezone

Is there any way by which I can get TimeZone value using time stamp

人走茶凉 提交于 2021-02-11 15:40:38
问题 This is the value which I have, Sun Mar 29 2020 02:55:00 GMT+0530 and I want to get,for example Asia/Calcutta as ouput. Thanks in advance. 回答1: Offset does not indicate zone get TimeZone value using time stamp No. You cannot determine a time zone from an offset. Many time zones can share the same offset-from-UTC (the number of hours-minutes-seconds ahead or behind the prime meridian). See the list of time zone names in Wikipedia. Click on the column header to sort by offset. Notice how often

Get current GMT offset from a timezone identifier

浪尽此生 提交于 2021-02-11 15:37:20
问题 How do I get the current GMT offset from a timezone identifier? Ideally, it would include the long form name too. For example: "America/Los_Angeles" //output: GMT-0700 (Pacific Daylight Time) It would be nice if it worked with ISO strings too, for example: 2020-12-21T03:57:00Z //output: GMT-0800 (Pacific Standard Time) 回答1: You can use the timeZone and timeZoneName options of the Intl.DateTimeFormat object as below to get the name of more common timezones, but lesser known ones will probably

Get current GMT offset from a timezone identifier

本秂侑毒 提交于 2021-02-11 15:36:13
问题 How do I get the current GMT offset from a timezone identifier? Ideally, it would include the long form name too. For example: "America/Los_Angeles" //output: GMT-0700 (Pacific Daylight Time) It would be nice if it worked with ISO strings too, for example: 2020-12-21T03:57:00Z //output: GMT-0800 (Pacific Standard Time) 回答1: You can use the timeZone and timeZoneName options of the Intl.DateTimeFormat object as below to get the name of more common timezones, but lesser known ones will probably

How to parse local time without a date with moment?

夙愿已清 提交于 2021-02-11 14:00:01
问题 Input 8:30 PM with the local date of May 12th 2020 while UTC date already May 13th 2020 Desired Output 2020-05-12 20:30:00 Actual Output 2020-05-13 20:30:00 Tried 3 things: result = moment('8:30 PM', 'h:mm A').format('YYYY-MM-DD HH:mm:ss'); result = moment.tz('8:30 PM', 'h:mm A', 'America/New_York').format('YYYY-MM-DD HH:mm:ss'); moment.tz.setDefault('America/New_York'); result = moment.tz('8:30 PM', 'h:mm A', 'America/New_York').format('YYYY-MM-DD HH:mm:ss'); 回答1: As user120242 says it seems

How to parse local time without a date with moment?

雨燕双飞 提交于 2021-02-11 13:57:13
问题 Input 8:30 PM with the local date of May 12th 2020 while UTC date already May 13th 2020 Desired Output 2020-05-12 20:30:00 Actual Output 2020-05-13 20:30:00 Tried 3 things: result = moment('8:30 PM', 'h:mm A').format('YYYY-MM-DD HH:mm:ss'); result = moment.tz('8:30 PM', 'h:mm A', 'America/New_York').format('YYYY-MM-DD HH:mm:ss'); moment.tz.setDefault('America/New_York'); result = moment.tz('8:30 PM', 'h:mm A', 'America/New_York').format('YYYY-MM-DD HH:mm:ss'); 回答1: As user120242 says it seems

moment-timezone setDefault not behaving as expected

那年仲夏 提交于 2021-01-29 04:48:08
问题 Using the following code: console.log(moment().toJSON()); moment.tz.setDefault("Europe/Brussels"); console.log(moment().toJSON()); I get the following result: 2019-05-12T10:39:12.851Z 2019-05-12T10:39:12.863Z However, when I read the documentation of moment-timezone, setDefault is supposed to set my default timezone on "Europe/Brussels", so the output should be: 2019-05-12T10:39:12.851Z 2019-05-12T11:39:12.863Z Apparently, setDefault cannot be used to what I want (which is generating a new

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)