moment / luxon

⏱ A library for working with dates and times in JS
https://moment.github.io/luxon
MIT License
15.23k stars 730 forks source link

Set timezone on .now() options #1462

Closed DevboiDesigns closed 1 year ago

DevboiDesigns commented 1 year ago

Describe the bug When passing timezone options to the .now() method, the wrong time is shown.

To Reproduce

const now = DateTime.now({ zone: 'America/New_York' })
console.log(now.minute, now.hour) // returns one hour off of what it should be

Actual vs Expected behavior Give me the time it currently is in New York

Desktop (please complete the following information):

Additional context Maybe this should be a feature but it seems like it would already be a feature. Let me know if I am mistaken.

Work Around I just used the fromJSDate() method and it worked correctly

diesieben07 commented 1 year ago

DateTime.now does not take any parameters. From its documentation:

Create a DateTime for the current instant, in the system's time zone.

For your use case you want DateTime.local, which allows you to set the zone, locale and many other options.