var beginDate = new Date(2019,1,12);
var endDate =new Date(2019,10,22);
//获取日期相差月份
var intervalMonth =(endDate.getFullYear()*12+endDate.getMonth())-(beginDate.getFullYear()*12+beginDate.getMonth());
//获取日期相差天数
var intervalDay=(endDate.getTime()-beginDate.getTime()) / 1000 / 60 / 60 / 24; //除1000是毫秒,不加是秒