moment.duration.days returns radically different result than asDays

Created on 12 Aug 2016  路  1Comment  路  Source: moment/moment

There's something I'm not getting. Either that or it's a bug. Tested with latest (2.14.1) version in Chrome 51.0.2704.103 on iOS 10.11.5.

var now = moment(),
      later = moment("20161023", "YYYYMMDD"),
      diff_ms = later.diff(now),
      dur = moment.duration(diff_ms, "ms");

console.log(dur.days());    // 11
console.log(dur.asDays());  // 72.06...

Most helpful comment

.asDays() returns the total duration, in units of whole and fractional days.

.days() returns the number of days that are remaining after accounting for .years() and .months().

>All comments

.asDays() returns the total duration, in units of whole and fractional days.

.days() returns the number of days that are remaining after accounting for .years() and .months().

Was this page helpful?
0 / 5 - 0 ratings

Related issues

slavafomin picture slavafomin  路  3Comments

chitgoks picture chitgoks  路  3Comments

IbraheemAlSaady picture IbraheemAlSaady  路  3Comments

nikocraft picture nikocraft  路  3Comments

dogukankotan picture dogukankotan  路  3Comments