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
114
votes
8 answers

Get timezone from users browser using moment(timezone).js

What is the best way to get client's timezone and convert it to some other timezone when using moment.js and moment-timezone.js I want to find out what is clients timezone and later convert his date and time into some other timezone. Does anybody…
nemo_87
  • 4,523
  • 16
  • 56
  • 102
8
votes
0 answers

Angular Unit Test - how simulate system clock timezone

How is it possible to simulate the system clock being set to another timezone in an Angular Unit Test with Karma/Jasmine. I am working an a custom datetime picker component. It has a bug that can only be reproduced when using it in a different…
spierala
  • 2,349
  • 3
  • 25
  • 50
7
votes
5 answers

Momentjs: How to convert date/time of one timezone to UTC date/time

I have a date/time with a timezone and want to convert it into UTC const date = '2019-04-10T20:30:00Z'; const zone = 'Asia/Kuala_Lumpur'; const utcDate = moment(date).tz(zone).utc().format(); console.log('UTC Date : ', utcDate); is my date variable…
Shivprsad Sammbhare
  • 410
  • 3
  • 7
  • 20
6
votes
1 answer

material-ui LocalizationProvider for a remote time zone

My app needs material-ui date and time pickers to operate on a remote time zone specified by the server. I'd like the today circle on the date picker to actually indicate today in the remote time zone, and I'd like to translate the datetimes in the…
Scott Lamb
  • 2,266
  • 1
  • 19
  • 21
6
votes
2 answers

MomentJS wrong output

I am converting Miliseconds to date and time using moment It gives me correct output as expected but while converting same date+time it gives me wrong output. I have used unix,valueOf moment methods. const moment =…
Zamir
  • 217
  • 2
  • 11
5
votes
1 answer

How to load momentjs timezones data asynchronously in Angular

I have just installed the package: npm install moment-timezone --save And in angular component I use it like this: import * as moment from 'moment-timezone'; moment().tz('America/New York'); I guess this adds all timezone data (900+kB) to the…
Liero
  • 25,216
  • 29
  • 151
  • 297
5
votes
1 answer

Vue modules, moment-timezone - How to load moment-timezone correctly and how to use the 2012-2022 data

I'm using the webpack template from vue-cli for my Vue project and I have both moment and moment-timezone installed in npm. In my single file components, I've been able to get moment to work with moment-timezone by including the following import…
Slotheroo
  • 925
  • 2
  • 9
  • 17
5
votes
1 answer

node.js: version of dependency (moment-timezone) changes at runtime

For the last day I researched a mysterious issue in which a moment-timezone feature would not work under particular, seemingly arbitrary circumstances. I discovered that the runtime version of my moment-timezone library was changing at some point…
joniba
  • 3,339
  • 4
  • 35
  • 49
4
votes
1 answer

I want to Change Timezone of Date Object In JavaScript

I want to change JavaScript Object Time zone. I am able to access time of the required timezone but date objects still shows my local timezone with it. new Date() output //Thu Nov 18 2021 16:30:23 GMT+0500 (Pakistan Standard Time) new…
4
votes
2 answers

How to get the canonical timezone name of a timezone alias?

I would like to create a function that converts timezone aliases names into the canonical name for said timezone. Status of timezones from Wikipedia For example if I had Africa/Accra I would like to be able to look up that Africa/Abidjan is the…
Souperman
  • 5,057
  • 1
  • 14
  • 39
4
votes
3 answers

Why is moment-timezone using a lot less space with webpack 4 and/or create react app 4?

With webpack 3, I was using moment-timezone-data-webpack-plugin to reduce my bundle size and it worked well. Tests showed it reduced the bundle size dramatically. I've now upgraded to webpack 4 and create-react-app 4, and it seems like this plugin…
John Bachir
  • 22,495
  • 29
  • 154
  • 227
4
votes
1 answer

Difference between two timestamps in hours minutes and seconds

I am trying to calculate the difference between two timestamp "2020-03-18T17:34:45.856Z", "2020-03-18T16:34:45.856Z" the difference should be like this: 2 hours 20min 30sec I have tried using return moment.utc(moment(startDate,…
juhi
  • 558
  • 1
  • 10
  • 19
4
votes
4 answers

Get client local timezone in js

I want to get the client machine local timezone. I tried moment-timezone npm package, with the following command moment.tz().zoneAbbr() But it is giving me Universal timezone ie UTC, but I want IST Can anybody please guide me how to get client…
khushboom
  • 45
  • 1
  • 1
  • 5
4
votes
0 answers

Moment-timezone can't load data in AWS Lambda

I'm using moment-timezone@0.5.23. const moment = require('moment-timezone'); ... const now = moment().tz('America/Los_Angeles'); console.log(now.format('dddd'); This works well when I run it on my laptop. However, when I deploy the code to my AWS…
chepukha
  • 2,371
  • 3
  • 28
  • 40
4
votes
2 answers

How to resolve moment-timezone import issue with meteor npm

I am trying to use the moment-timezone npm package in my meteor app to no avail. If I use the atmosphere package, everything runs just fine. However I would like to get the npm package running as the atmosphere one is no longer being maintained. I…
mpzo
  • 41
  • 1
  • 3
1
2 3
26 27