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

Where is the docs about keepTime parameters of tz() ? #595

Closed
erakis opened this issue Sep 6, 2019 · 2 comments
Closed

Where is the docs about keepTime parameters of tz() ? #595

erakis opened this issue Sep 6, 2019 · 2 comments

Comments

@erakis
Copy link

erakis commented Sep 6, 2019

Hi,

I looked for the best I could, but could not find any information about the keepTime parameter of the

moment.tz (..., keepTime)
               ¯¯¯¯¯¯¯¯¯¯

function.

I think I understand what the parameter is doing :

When the keepTime parameter is missing or false, the time is only interpreted to the specified timezone without changing the internal value. When the keepTime parameter is true, the internal time is adjusted so that the time is created at the local time of this timezone instead of transposing from gtm.

Sorry It's poorly written but this is the best I can do. Maybe someone could explain it better ? Anyway, a minimum of documentation on that would have been very helpful.

Refs :

@qfan
Copy link

qfan commented Jan 31, 2020

It's a bit confusing. Here's how I understand it:

If keepTime=true, we only set the time zone info, causing the actual moment to change, but the face value of the time is kept.

If keepTime=false, the time is converted to the given timezone, so the displayed date and time may change, but the result refers to the exact same moment before calling tz.

moment('2020-01-30T18:00:00-0800').tz('America/New_York').format()
"2020-01-30T21:00:00-05:00"
moment('2020-01-30T18:00:00-0800').tz('America/New_York', true).format()
"2020-01-30T18:00:00-05:00"
moment('2020-01-30T18:00:00-0800').tz('America/New_York', false).format()
"2020-01-30T21:00:00-05:00"
moment.version
"2.24.0"

@marwahaha
Copy link
Member

duplicate of #586

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

3 participants