I am new to moment.js. I want to convert milliseconds to days. When I tried in normal converter in google it is showing 377.7613437963 days
, but programatically it is showing 11 days
.
var duration = moment.duration(32638528433, 'milliseconds');
var days = duration.days();
console.log(days);
You need to use asDays()
if you want 377.7613437963
as output.
As the docs says:
As with the other getters for durations,
moment.duration().days()
gets the days (0 - 30).
moment.duration().asDays()
gets the length of the duration in days.
Here a live example:
var duration = moment.duration(32638528433, 'milliseconds');
var days = duration.asDays();
console.log(days);
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.17.1/moment.min.js"></script>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With