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
1
vote
0 answers

MomentJS bug diff between 2 dates

I have a problem, I want the difference between 2 dates and I do not have the same result: let start = moment('2022-11-01 00:00:00').tz('Europe/Paris'); start = start.subtract(6, 'months'); const end = moment('2022-11-01…
w-jerome
  • 11
  • 1
1
vote
3 answers

Convert Only Time to The Relevent Timezone

I am using moment js to get only the UTC time. const time = moment().utc().format('HH:mm:ss'); example output is like this - "07:57:49" I want to change this time value to relevant timezone value. const americaTime =…
Rishan.RM
  • 43
  • 4
1
vote
2 answers

Converting date/time to a different timeZone using MST7 or AST4 formats

I will get timeZone from the backend in the form of MST7 or AST4 I have to convert current user time to this timeZone I am trying to do something like this import moment from 'moment-timezone'; ..... const convertedTime = moment.tz(new Date(),…
kumar
  • 708
  • 4
  • 15
  • 39
1
vote
1 answer

Stop moment.tz from changing date when using timezones

I am trying to use the moment.tz library however the dates keep changing in new timezones since the time is set at midnight (0:00:00). I would like the dates to be unchanged when changing timezones. Essentially I have const checkin =…
Code4fun
  • 21
  • 2
1
vote
2 answers

MomentJS - Showing the wrong time for Pacific Timezone

I did not write the code involving Moment. But I'm tying to convert it to plain JavaScript. moment.tz.add("America/Los_Angeles|PST PDT PWT PPT|80 70 70…
1
vote
0 answers

Webpack and moment-timezone latest.json: Unexpected token "m" (0x6D) in JSON at position 0 while parsing near "module.exports = {\"v..."

Using Webpack 5 and the latest version of moment-timezone I get the following error. Please note that even without json-loader, which should not be necessary, I still get this error. ERROR in…
1
vote
1 answer

How to find time from timezone standard name using moment

I have the time zone info as shown in below JSON. {"timezone_standard_name": "(UTC-06:00) Central Time (US & Canada)"}. Is it possible to find the date and time for the above time zone. I have already tried to find UTC time then add the offset but…
Ebison J
  • 47
  • 1
  • 7
1
vote
1 answer

How to get the current time based of a UTC time using moment js

I have the following list of array that populates world timezones how do i get whats the actual time based on what a user selected. if the user selects the first option (UTC-12:00) International Date Line West how do i get the current time ?
deanpillow
  • 121
  • 1
  • 10
1
vote
1 answer

How to pass in dynamic value into toLocaleTimeString

So I'd like to pass in a dynamic value into toLocaleTimeString. The way the time is formatted is going to change based on the user location. For example time for a user in the UK should be something like 18:00:00, while for someone in America it…
nickcoding2
  • 142
  • 1
  • 8
  • 34
1
vote
1 answer

two different dates are returned in momentjs timezone for same set time?

Even the value I set for the time in the moment.js timezones same following two different approaches the value of the date returned is different moment("02:00","HH:mm").tz('America/Chicago').format() returns 2022-03-31T15:30:00-05:00…
prashanthh
  • 21
  • 4
1
vote
0 answers

ERROR in ../node_modules/@types/moment-timezone/moment-timezone.d.ts:63:11 - error TS2451: Cannot redeclare block-scoped variable 'tz'

I tried to install ( "ngx-persian-datepicker": "^0.1.3" ) on my angular boilerplate framework. but wen i run "npm start" , I get this error. ERROR in ../node_modules/@types/moment-timezone/moment-timezone.d.ts:63:11 - error TS2451: Cannot redeclare…
1
vote
1 answer

.tz() not recognize as function in Next.js and React

I am learning Next.js as my side project and I encountered a method call error. The error is at the tz function as is the . From the ide, the error is shown as in Code: import React from "react"; import Image from "next/image"; // import moment…
1
vote
1 answer

Get the next Monday in a user's timezone

This post was very useful Getting the date of next Monday when it comes to figuring out how to get the next Monday in UTC time. I have the following problem. I want to get the next Monday in user A's timezone and then convert that to user's B…
Rue Vitale
  • 1,549
  • 4
  • 17
  • 24
1
vote
0 answers

How to ignore IANA backward compatible values of timezone in moment js library or javascript Intl API?

I am using moment-timezone package to get current time zone values. I need value like America/New_york, Asia/KolKatta. import * as Moment from 'moment-timezone'; Moment.tz.guess() It works fine, but gives Asia/Calcutta instead of…
Always_a_learner
  • 4,585
  • 13
  • 63
  • 112
1
vote
1 answer

How can I get a time zone name with the current location spelling?

I am use moment library for getting time zone moment.tz.guess() which is returning 'Asia/Calcutta' (old name), instead of that I want the latest name which is 'Asia/Kolkata' (new name). Or any other way to get this new name time zone.
jenish lila
  • 131
  • 7