Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get a timespan in milliseconds using momentjs

I try the following to get a timespan in milliseconds:

moment(0).minute(10).milliseconds()

The idea is to have a simple and readable way to convert timespans into milliseconds. But unfortunately this will always return 0, the initial time.

like image 879
Andreas Köberle Avatar asked Oct 20 '25 12:10

Andreas Köberle


2 Answers

I think this is what you actually want to do:

moment.duration(10, "minutes").asMilliseconds();
like image 67
landons Avatar answered Oct 23 '25 02:10

landons


I don't know if I got your question, but we can use JavaScript for timestamps

var start = new Date().getTime();
var elapsed = new Date().getTime() - start;
like image 33
Anton Avatar answered Oct 23 '25 01:10

Anton



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!