日期应该是:
var last7DayStart = moment().startOf('day').subtract(1,'week');
var lastMonthThisDay = moment().startOf('day').subtract(1,'month');
var yesterdayEndOfRange = moment().endOf('day').subtract(1,'day');
那么如果它是一个 javascript 过滤器,我会使用lodash并执行以下操作:
var javascriptArrayOfObjectsWithDates = [
{ date : '2015-12-11T11:12:14.635Z', anotherProperty: 0 },
{ date : moment().subtract(1, 'day' ).format(), testThis: 'works!'}
];
var filteredObjects = _.filter(javascriptArrayOfObjectsWithDates,
function(each){
return moment(each.date)
.isBetween(last7DayStart, yesterdayEndOfRange) ;
});