rotaready / moment-range

Fancy date ranges for Moment.js
The Unlicense
1.69k stars 202 forks source link

valueOf with specific unitOfTime #269

Open NinjaDev06 opened 5 years ago

NinjaDev06 commented 5 years ago

I would like to get the duration of the range in any formats not only in milliseconds. The method valueOf may received unitOfTime.Base as a parameter.

Example

const start = moment('2011-04-15', 'YYYY-MM-DD');
const end   = moment('2011-04-16', 'YYYY-MM-DD');
const range = moment.range(start, end);

const hours = range.valueOf('hours'); // 24
const days = range.valueOf('days'); // 1