how find earliest of set of dates. have following code works fine:
var dates = [date1,date2]; // list of javascript dates var start = moment(new date(9999, 0, 1)) // wished 1 line in momentjs + underscorejs _.foreach(dates, (date) => { if (moment(date).isbefore(start)) { start = moment(date); } });
i hoping there neater way (in 1 line). prefer use simpler function in underscore (min not work on dates) / momentjs.
i found _.min reliable on moment
instances. following works:
var dates = _.map([date1,date2],function(date){return moment(date)}); var start = _.min(dates);
nevermind.