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
Support for decimal milliseconds #3256
Comments
Because Moment.js is a wrapper for the Date object in JavaScript, we are limited to three decimal places (milliseconds). This is because that is all that the date object supports, so there is truly no way to store more. You shouldn't have to monkey patch anything to get seven decimal places to display or parse though. Just be aware that only the first three will actually be used. moment('2016-01-01T05:21:22.1234567Z').format('YYYY-MM-DDTHH:mm:ss.SSSSSSS')
"2015-12-31T23:21:22.1230000" Note that the output is zero filled, but there are seven digits both ways. |
Maggie,
for me I really need those extra digits. Zeros are not good enough.
manually parses the milliseconds from the input string (if it is
moment.js library at this point - it would no longer be a wrapper for a
documentation? Right now the millisecond truncation is implied from the
Regards, |
Hi @maggiepint, I am looking for the same. After debugging through Since the resulting value is a string, I don't see why it zero fills it🤔🤔🤔
It prints Further, I noticed older version of I will have to write a custom formatter now to retain correct info in the date unless a change is done on |
(ver 2.13.0)
The ISO standard allows for any number of decimal seconds before the 'Z' in a dateTime string. The .net platform seems to use 7 decimal places - while the moment.js library is only parsing out the first 3 decimal places.
I have monkey patched the formatter (toISOString()) to pull the full 7 digits from the creation object - but this is a terrible hack. Patching the parser would be much better - but is beyond my current understanding.
Perhaps there is another work-around?
The text was updated successfully, but these errors were encountered: