Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setting default time zone is ignored by moment #869

Closed
ramik91 opened this issue Jul 8, 2020 · 3 comments
Closed

Setting default time zone is ignored by moment #869

ramik91 opened this issue Jul 8, 2020 · 3 comments

Comments

@ramik91
Copy link

ramik91 commented Jul 8, 2020

I upgraded moment-timezone to 0.5.31 and moment to 2.27.0 in our React project. Tests started to fail due to issue described below. Is it now necessary to use moment-timezone imports only in order to get timezone aware date object?

Repro steps:

import momentTimezone from 'moment-timezone';
import moment from 'moment';

momentTimezone.tz.setDefault('America/Chicago');

const tzDate = momentTimezone('2019-06-25T12:30:00+00:00');
const date = moment('2019-06-25T12:30:00+00:00');


console.log('tzDate:,' tzDate.format('M/D/YYYY h:mm A'));
console.log('date:', date.format('M/D/YYYY h:mm A'));

Result:

tzDate: 6/25/2019 7:30 AM
date: 6/25/2019 12:30 AM

Expected:

tzDate: 6/25/2019 7:30 AM
date: 6/25/2019 7:30 AM
@mukeshprajapati-kombee
Copy link

I am also getting my local system timezone after setting another default timezone.

@gongAll
Copy link

gongAll commented Aug 12, 2020

Me too. I have traced the error to the [email protected] version. [email protected] works just fine.

@ichernev
Copy link
Contributor

I'm pretty sure this is the same as #892

Closing this in favor of the other one, please check with latest moment/moment-timezone, also I see you're using new js module system (which means there is some compat layer). Try with regular require in a new project (with no other dependencies), if the problem is gone it's likely due to multiple moment versions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants