#4649·moment

[bug] moment.duration accepts floating point milliseconds

Author: martin770Created Jun 1, 2018Updated Sep 2, 2026
Labelsfloating-point

The documentation states:

    To get the number of milliseconds in a duration, use moment.duration().milliseconds().
    It will return a number between 0 and 999.

However, moment.duration(1.23).milliseconds() returns 1.23 moment.duration(1.23).asMilliseconds() returns 1.23 (which seems correct)

To be consistent with the other duration functions (e.g. seconds(), asSeconds(), minutes(), asMinutes()), moment.duration(1.23).milliseconds() should return 1 (an integer between 0 and 999), but moment.duration(1.23).asMilliseconds() should return 1.23.