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().toISOString() bug, if you pass in a 18th, it returns 17th #947
Comments
As you can see |
@ichernev , I don't fully get your point? Does displaying in specific ways means when I pass in 17th, I should get 18th? How do I pass in 18th and get back 18th? thanks. |
That might work for you then: > moment().format('YYYY-MM-DD[T]HH:mm:ss.SSSZZ')
'2013-07-23T14:54:20.176-0700' Or > moment().format('YYYY-MM-DD[T]HH:mm:ss.SSS')
'2013-07-23T14:54:20.176' If you don't care about the timezone, and just want to display the time. |
@ichernev, many thanks. |
You can use keepOffset parameter of toISOString: toISOString(keepOffset?: boolean): string; => moment().toISOString(true) |
Is this really right?
outputs:
I think most people passing in a specific date to moment and formatting it as an toISOString would expect the date to not change. Why doesn't keepOffset default to true if it makes the function behave in a more predictable manner? I know moment are being consistant with the native JavaScript Date toISOString function as per ES2015 but even so this just doesn't feel like expected behaviour. |
This problem seems to be caused by moment().toISOString() introduced here:
http://momentjs.com/docs/#/displaying/as-iso-string/
moment().toISOString();
I might but in the console if I do:
It will return:
Now if I call toISOString() on it, the date suddenly becomes 17th:
the above will return the 17th instead of 18th:
The text was updated successfully, but these errors were encountered: