moment-timezone

Is Zone abbreviation using moment-zone library a dynamic

依然范特西╮ 提交于 2020-07-10 03:37:25
问题 I am using moment timezone library to show the zone abbreviation after the timestamp. I am using the following snippet to show the zone abbreviation of New York, USA var timeZone = moment.tz.guess(); const zoneName = moment.tz(timeZone).zoneName(); return moment().tz("America/New_York").zoneName(); This returns me the Zone abbreviation EDT . My question is: when winter will come will it automatically return EST ? 回答1: Yes, it will. var jun = moment("2014-06-01T12:00:00Z"); var dec = moment(

momentJS: Getting wrong timestamp from date in a different timezone

亡梦爱人 提交于 2020-01-05 06:54:06
问题 There is one time input i.e. start_time I am trying to get timestamp in milliseconds for these inputs let start_time = "17:05:00"; var start_date_moment = moment(start_time, "HH:mm:ss"); console.log(start_timestamp); output is -> moment("2019-04-24T17:05:00.000") This output remains same on server and local But when I am trying to get unix timestamp in milliseconds in the same way var start_timestamp = moment(start_time, "HH:mm:ss").valueOf(); On server at different timezone console.log(start

Moment js interval for a day in 12 hours format

谁说胖子不能爱 提交于 2019-12-24 01:12:59
问题 In 12 hours format,i have to create a interval of 15 minutes in moment which is working fine with 30 minutes interval. var hours = []; for (let hour = 0; hour < 24; hour++) { hours.push(moment({ hour }).format('h:mm a')); hours.push( moment({ hour, minute: 30 }).format('h:mm a') ); } console.log( hours); But when work with 15 minutes shows the wrong format.can anone help? var hours = []; for (let hour = 0; hour < 24; hour++) { hours.push(moment({ hour }).format('h:mm a')); hours.push( moment(

Array with number of days using moment

倾然丶 夕夏残阳落幕 提交于 2019-12-11 15:37:59
问题 I am trying to create an array with number of days between two dates. The dates can be anything but i am using the following for this example. Start : 11/30/2018, End: 09/30/2019 Array= [30,31,29,30....31] What i am trying to do: Here date ranges from 30 to 30 and 30-29. I have the following code: const start = "11/30/2018"; const end = "09/30/2019"; const dates = []; const mstart = moment(new Date(start)); const mend = moment(new Date(end)); for (let i = 0; mstart < mend ; i++) { const

How to produce recurrence rschedule durations with timeshifts

独自空忆成欢 提交于 2019-12-11 06:16:31
问题 I am using rSchedule to produce working hour intervals.But timezone is ignored. How can I achieve it? The input is working hour intervals in a day, with timezone as below. const input = { workingHours:[{start:9, end:12}, {start:13, end:18}], timeZone:'Europe/Berlin' }; With the below code, I am expecting to produce intervals with respect to day light shiftings in a year. However, the produced output ignores the timeZone I provided. import { Schedule } from "@rschedule/core/generators"; import

moment timezone adjust timestamp to a timezone and return value

梦想的初衷 提交于 2019-12-02 19:02:54
问题 I try to modify timestamps timezone with moment-timezone and I want to get the modified value with the applied offset var newTimestamp = momentTz.tz(timestamp, 'Europe/Berlin') so here is what I try var results = {}; for (var timestamp in timestamps) { var commitCount = timestamps[timestamp]; console.log(typeof timestamp) console.log(timestamp) console.log(moment(timestamp).format()) //console.log(moment.tz(timestamp, 'Europe/Berlin')) //results[ moment.tz(timestamp, 'Europe/Berlin')] =

moment timezone adjust timestamp to a timezone and return value

十年热恋 提交于 2019-12-02 10:19:51
I try to modify timestamps timezone with moment-timezone and I want to get the modified value with the applied offset var newTimestamp = momentTz.tz(timestamp, 'Europe/Berlin') so here is what I try var results = {}; for (var timestamp in timestamps) { var commitCount = timestamps[timestamp]; console.log(typeof timestamp) console.log(timestamp) console.log(moment(timestamp).format()) //console.log(moment.tz(timestamp, 'Europe/Berlin')) //results[ moment.tz(timestamp, 'Europe/Berlin')] = commitCount; }; here is a snippet from log string 1528063200 Invalid date How do I get the new timestamp? It