-
-
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
dayjs.utc('....') parases milliseconds incorrectly #2459
Comments
I just figured out a bug we have today due to the same thing. I couldn't figure out why values coming out of our app code, using dayjs, weren't correct but the timestamps in the postgresql 12 database were. It's easy to recreate with the latest version of dayjs:
Comparing to moment 2.29.4:
|
@CramericaIndustries have you figured out a workaround? |
This seems to work:
As opposed to:
|
Nevermind that, I lose the UTC... |
Here is my "it's late in the day" workaround - don't use // workaround https://github.com/iamkun/dayjs/issues/2459 by using Date
if (!str.endsWith('Z')) str += 'Z'
return new Date(str).toISOString() |
|
This is pretty embarrassing - the default More so since this bug still hasn't been fixed over a year later. |
The same issue seems to occur when parsing a date with new Date('2024-01-01T08:00:00.06').getMilliseconds(); // output is 60 ( correct )
dayjs('2024-01-01T10:00:00.06').millisecond(); // output is 6, should be 60 |
Describe the bug
When parsing a timestamp using
utc()
the Milliseconds part is interpreted incorrectly.The timestamp is from a postgresql database. pgsql datatype is "timestamp without time zone".
Expected behavior
".02" miliseconds should be interpreted as "20" milliseconds and not as "2"
".2" miliseconds should be interpreted as "200" milliseconds and not as "2"
Information
The text was updated successfully, but these errors were encountered: