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

With your time zone set to Brazil, moment('2020-11-01').endOf('month') returns '2020-12-01' #4727

Closed
itai-katz opened this issue Aug 1, 2018 · 3 comments

Comments

@itai-katz
Copy link

Description of the Issue and Steps to Reproduce:
Switch your computer timezone to be Brazil
run console.log( moment('2020-11-01').endOf('month').format('YYYY-MM-DD'))
you will receive '2020-12-01' instead of '2020-11-30'

Other information that may be helpful:
Brazil Daylight saving time ends in November 1st 2020, my guess is this is the root cause.
https://www.timeanddate.com/time/zone/brazil/sao-paulo

  • The time zone setting of the machine the code is running on
    Brazil GMT-3
  • The time and date at which the code was run
    2018-08-01 6:50 PM
  • Other libraries in use (TypeScript, Immutable.js, etc)
    verified with fiddle js and just moment.js latest version

If you are reporting an issue, please run the following code in the environment you are using and include the output:

with timezone set to GMT-3 Brazil
console.log( moment('2020-11-01').endOf('month').format('YYYY-MM-DD'))
'2020-12-01'

with timezone set to EDT US east coast
console.log( moment('2020-11-01').endOf('month').format('YYYY-MM-DD'))
'2020-11-30'
@ashsearle
Copy link
Contributor

ashsearle commented Aug 2, 2018

Probably related to #3132, which should be fixed by PR #4338 (been waiting for this to be merged for a while.)

@moacir-selinger
Copy link

Nice! :) 👍

@marwahaha
Copy link
Member

In 2.24.0:

fmt = d => console.log(d.format() + " " + d.tz())
fmt(moment.tz('2020-11-01', 'America/New_York').endOf('month'))  // 2020-11-30T23:59:59-05:00 America/New_York
fmt(moment.tz('2020-11-01', 'America/Sao_Paulo').endOf('month')) // 2020-11-30T23:59:59-02:00 America/Sao_Paulo

Please re-open if you still have issues.

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

4 participants