MomentJS - Milliseconds


Advertisements

This method will give no of milliseconds in a duration. It will show the value in the range 0-999. If the value is greater than 999, it will display as 0. To get the length of duration in milliseconds, use asMilliseconds() method.

Syntax

moment.duration().milliseconds();
moment.duration().asMilliseconds();

Example

var a = moment.duration(500).milliseconds();

Output

Milliseconds

Example

var a = moment.duration(1000).milliseconds();

Output

Duration Milliseconds

Example

With asMilliseconds, you will be able to get the value in milliseconds as shown below

var a = moment.duration(1000).asMilliseconds();

Output

Duration asMilliseconds
momentjs_durations.htm
Advertisements