我有2个不同的日期,我想从这两个日期获得月份
var from = '08-01-2016';
var to = '10-01-2016';
我希望从这些日期起2个月不同。请帮忙。
答案 0 :(得分:0)
var past_date = new Date('08-01-2016');
var current_date = new Date('10-01-2016');
var difference = (current_date.getFullYear()*12 + current_date.getMonth()) - (past_date.getFullYear()*12 + past_date.getMonth());
console.log("Month Difference : " +difference);