Questions tagged [moment-timezone]

Moment-timezone is an add-on for Moment.js that provides IANA time zone support. Use this tag for issues with moment-timezone, but also tag it with [moment]. NOTE: As of September 2020, the Moment team recommends you chose a different library for new projects. See the Project Status section of the Moment docs. On StackOverflow, please refrain from recommending Moment as a solution unless Moment is specifically asked for in the question.

Moment-timezone is an add-on for Moment.js that provides IANA time zone support.


Important:

As of September 2020, the Moment team recommends you choose a different library than Moment for new projects. Please read https://momentjs.com/docs/#/-project-status/

On StackOverflow, please refrain from recommending Moment as a solution unless Moment is specifically asked for in the question.

401 questions
2
votes
2 answers

ERROR in /node_modules/moment-timezone/index.d.ts (47,77): ';' expected. how to fix

I'm working in an Angular 4 application and everything worked fine until I clone my repo and runned npm install and ng serve This error seems to be the problem ERROR in C:/Users/mypcuser/Desktop/myproject/node_modules/moment-timezone/index.d.ts…
Sergio Mendez
  • 1,311
  • 8
  • 33
  • 56
2
votes
1 answer

Generating 30 minutes time slots going into next day using moment.js

var x = { next-slot: 30, start-time: '21:00', end-time: '05:00' } I want to generate time slots , starting from start Time till end Time. Output should be [21:00, 21:30, 22:00, 22:30, 23:00, 23:30, 00:00, 00:30, 01:00, 01:30, 02:00,…
2
votes
2 answers

Get code from country or zone name to set locale() moment.js

I'm using moment.js with moment timezone in it. I was trying to find how to get code 'fr' from zone name 'Europe/Paris' all day, but with no luck. I read all their docs and couldn't find that function either, so i need help on this one. Closest what…
Stefan
  • 627
  • 6
  • 19
2
votes
1 answer

convert from now() using Date to Moment Timezone from America/Los_Angeles

I would like to know if it is possible in typescript to convert Date() to moment().tz("America/Los_Angeles").format(); I have tried import { MomentTimezone } from 'moment-timezone'; const moment : MomentTimezone = new MomentTimezone(Date(),…
Sandro Rey
  • 2,429
  • 13
  • 36
  • 80
2
votes
3 answers

How to add time zone to specific format in momentjs?

I am trying to get specific format of datetime with time zone i am getting string of time format which is shown below var dateTime = "2020-06-01T01:50:57.000Z CDT" I need to convert the format in to const offsetTime = moment(date).add("-0.00",…
user11159070
  • 51
  • 1
  • 6
2
votes
1 answer

how to get specific country time zone using momentjs

I'm trying to get abbreviations of timezones with Moment.js. still i am not getting the output Moment.js provides https://momentjs.com/timezone/docs/#/using-timezones/getting-country-zones/ moment.tz.zonesForCountry('US') which gives list of…
user13465472
  • 107
  • 9
2
votes
1 answer

moment-timezone change utc to default timezone

Context: I need to parse datetimes from UTC into the timezone currently set as default by moment-timezone with moment.tz.setDefault. Attempt (functional): const task = { startDate: '2020-03-24 14:00:00' }; const startDateMoment =…
Alberto Rivera
  • 3,652
  • 3
  • 19
  • 33
2
votes
2 answers

Convert dates to different timezones without MomentJS

I have a quite data-heavy app I'm working on, and I can see in Chrome's profiler that moment is chewing up an enormous amount of CPU when working with large datasets. I'm aware it's reasonably well-known for this, but I don't know how I'd format…
MitchEff
  • 1,417
  • 14
  • 29
2
votes
1 answer

Displaying data in different timezone

Summary I have a large collection of data with various datetimes. Currently I have been able to group all my data to display properly in a local timezone; however, when trying to display this data in a different timezone the lines on a lineChart get…
Shawn Pacarar
  • 414
  • 3
  • 12
2
votes
1 answer

How to produce recurrence rschedule durations with timeshifts

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}], …
2
votes
1 answer

How to transform a localTimeString to utcTimeString and back to localTimeString using moment-timezone

When someone in my application picks a date and time and I want to store that DateTime in UTC time, how do I transform the stored DateTime back to the user's local timezone? const moment = require('moment-timezone') const myTimeZone =…
user2386092
  • 186
  • 2
  • 9
2
votes
2 answers

Create new Date object by using moment.js

I have string: date = "2019/1/16 00:00 +0900" I'm in New York (timezone -5), I want to create an Date object like that: Wed Jan 16 2019 00:00:00 GMT+0900 I can't use javascript to convert. It will return with timezone -5. I use…
Corey
  • 107
  • 3
  • 10
2
votes
2 answers

How to use moment-timezone for mapping with C# TimeZoneInfo?

I need to make illusion of working in the selected by the user timezone. The problem that server and client code are stick to javascript date. So to achieve the requirement I have made mannualy mapping from utc to the date on the client side:…
Nikita
  • 1,019
  • 2
  • 15
  • 39
2
votes
1 answer

Moment js interval for a day in 12 hours format

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')); …
Mohamed Sahir
  • 2,482
  • 8
  • 40
  • 71
2
votes
1 answer

moment.js strict mode time format validation with time zone

I'm trying to get moment.js to validate (strict mode) a user-entered date/time with time zone. Example: moment("2018-01-20 06:30 PDT", "YYYY-MM-DD HH:mm Z", true).isValid(); This returns false, though the user-entered value is valid for my…
CapaJC
  • 29
  • 5