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

Moment wrong after setting default timezone #513

Closed
SudoPlz opened this issue Jul 21, 2017 · 1 comment
Closed

Moment wrong after setting default timezone #513

SudoPlz opened this issue Jul 21, 2017 · 1 comment

Comments

@SudoPlz
Copy link

SudoPlz commented Jul 21, 2017

Hey there @timrwood

Check this fiddle http://jsfiddle.net/sudoplz/zgfbd2mf/4/

Before setting the default timezone everything seems to be working fine, but after it's been set all hell breaks loose.

Here's the code:

var beforeTz = moment('1500673235723', 'x').format('h:mma DD/MM/YYYY');
moment.tz.setDefault('Europe/Athens')
var afterTz = moment('1500673235723', 'x').format('h:mma DD/MM/YYYY');

alert(`\nBEFORE: ${beforeTz}\nAFTER: ${afterTz}`);

screen shot 2017-07-22 at 00 14 27

I've tried with various versions.
It seems to be working when using moment-timezone: 0.3.1 but if I go above that it just fails to read that timestamp.

which today are:

"moment": "2.18.1",
"moment-timezone": "0.5.13",

Any idea why that's happening?
ty

@mattjohnsonpint
Copy link
Contributor

Hi! This is a duplicate of a known bug, #347. Workaround: Pass the timestamp as a number rather than parsing it with x.

Also note that Tim has moved on to other things.
https://medium.com/@timrwood/moment-endof-term-522d8965689

Cheers!
-Matt

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

2 participants