167
rated 0 times
[
169]
[
2]
/ answers: 1 / hits: 5881
/ 11 Years ago, wed, january 29, 2014, 12:00:00
I have to two dates from
and to
. I want to get all of the month names between these two dates.
Following is my code
var monthNames = [ January, February, March, April, May, June,
July, August, September, October, November, December ];
function diff(from, to) {
var datFrom = new Date('1 ' + from);
var datTo = new Date('1 ' + to);
var arr = monthNames.slice(datFrom.getMonth(), datTo.getMonth() + 1);
}
above code works for following inputs
diff('September 2013', 'December 2013');
but it does not work for this
diff('September 2013', 'February 2014');
How can I make it work?
More From » jquery