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

Should be an option to return local times from toISOString #1751

Closed
icambron opened this issue Jul 2, 2014 · 4 comments
Closed

Should be an option to return local times from toISOString #1751

icambron opened this issue Jul 2, 2014 · 4 comments

Comments

@icambron
Copy link
Member

icambron commented Jul 2, 2014

toISOString always returns UTC times. We should support a flag that lets you return the local time instead of requiring the user to do:

moment().format('YYYY-MM-DD[T]HH:mm:ss.SSSZ');
@ichernev
Copy link
Contributor

ichernev commented Jul 2, 2014

+1

Maybe something like

moment().toISOString({tz: false}); // .utc().format()
moment().toISOString({tz: "local"});  // .local().format()
moment().toISOString({tz: true});  // depend on the object (utc, local, zoned moment)
moment().toISOString({tz: "05:00"});  // .zone(str).format()

Internally it would do .local, .utc or .zone. Now it only does .utc.

@marwahaha
Copy link
Member

This was done in 2.20.0:

moment().toISOString(true)

https://momentjs.com/docs/#/displaying/as-iso-string/

@Haider8
Copy link

Haider8 commented Mar 31, 2019

This was done in 2.20.0:

moment().toISOString(true)

https://momentjs.com/docs/#/displaying/as-iso-string/

I am doing this but still not able to get local time. Can somebody help me please :)

Doing this:

moment().subtract(1, 'Y').toISOString(true)

@pironim
Copy link

pironim commented Apr 30, 2019

moment().toISOString(true) not working as expected for 2.7.0 . not sure about latest version but flag does not help.

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

No branches or pull requests

5 participants