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

defaulting to current date-time uses UTC (ignores timezone) #874

Open
vishnukumarnekkanti opened this issue Jul 19, 2020 · 3 comments
Open
Labels

Comments

@vishnukumarnekkanti
Copy link

vishnukumarnekkanti commented Jul 19, 2020

Moment created from formatting time sets the date as the UTC date rather than the date of the default timezone
EX:

m = require('moment-timezone')
_ = m.tz.setDefault("Asia/Kolkata")
console.log(m())
console.log(m("T22:00","THH:mm"))

Output:
moment.parseZone("2020-07-20T03:33:18.943+05:30")
moment.parseZone("2020-07-19T22:00:00.000+05:30")

@Tugzrida
Copy link

I'm pretty sure I'm seeing some behaviour related to this.
It's currently 2020-07-27 in Sydney, however UTC is still the 26th. Any value I have tried from 00:00 to 23:59 gives a date on the 26th.

moment.tz("Australia/Sydney").format()
-> "2020-07-27T02:24:03+10:00"

moment.tz("00:00", "H:m", "Australia/Sydney").format()
-> "2020-07-26T00:00:00+10:00"
moment.tz("23:59", "H:m", "Australia/Sydney").format()
-> "2020-07-26T23:59:00+10:00"

If I however advance my clock to a point where Sydney and UTC are both in the same day(27th), I get stamps for the 27th as I would expect.

@ichernev ichernev added the bug label Aug 26, 2022
@ichernev
Copy link
Contributor

ichernev commented Aug 26, 2022

Yep, I can reproduce this issue on latest moment + moment-timezone. Some mechanism to request "current local time" from moment to moment-timezone might be required.

@ichernev ichernev changed the title moment from formatted time has UTC date instead of the default timezone defaulting to current date-time uses UTC (ignores timezone) Aug 26, 2022
@Junaid20001
Copy link

can you assign this project to me

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

No branches or pull requests

4 participants