-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
fromNow() gives inconsistent results between UTC & local mode #646
Comments
Here is my result and seems that it works as normal. I'm in UTC+8 (Beijing). By viewing documents and code, I found But So, I think maybe In some special cases, the I can't completely guarantee that I am right. Maybe need some discussion? |
The difference is that your timezone is ahead of UTC (+8), and my timezone is behind UTC (-7). If I manually change my laptop's timezone to +8, However, there's another way to replicate the difference without changing your timezone. Instead of subtracting 37 hours, add 37 hours. In other words: let currentTimestamp37hrsAgo = currentTimestamp + (37 * 60 * 60 * 1000); Then you'll get the different results in your Beijing timezone.
|
@denchen Got it. I will check the source code and try to find out where the problem lies. |
Thank you for addressing this issue. When can we expect a new release that includes this fix? A rough estimate would be fine. |
🎉 This issue has been resolved in version 1.8.16 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Describe the bug
I've found a situation where
fromNow()
gives different results from MomentJS, and it gives different results depending on if you're in UTC mode or not.Given the following:
Output of the above:
Here's a more extensive reproduction on Runkit
If it helps, my local timezone is PST (-07:00)
Expected behavior
It is my understanding that
fromNow()
should not "care" about timezones, and it's based strictly off of the difference in absolute time.fromNow()
should give the same results, regardless of if we're using.utc()
or not. I didn't check to see iftoNow()
also has the same problem, but I'd assume so.Information
1.8.15
MacOS 10.14.6
Chrome 75.0.3770.142
-07:00 DST (Pacific Daylight Time)
The text was updated successfully, but these errors were encountered: