node.js中2个日期之间的月份数

时间:2016-03-30 09:03:41

标签: node.js

以下是我必须找到几个月的两个日期。

Sun Mar 01 2015 05:30:00 GMT+0530 (IST)
Tue Sep 01 2015 05:30:00 GMT+0530 (IST)

我搜索了很多,但没有人代表上述格式。帮我解决这个问题。提前致谢。

1 个答案:

答案 0 :(得分:1)

var date = new Date('Sun Mar 01 2015 05:30:00 GMT+0530');

var date1 =  new Date('Tue Sep 01 2015 05:30:00 GMT+0530');

var diff = date1.getMonth() - date.getMonth();

console.log(diff)