Am looking for something where I could get a array of next three months in number from the current month , i have tried to get the month in string but looking for something like eg : current month is 11 (ie) November so it should return 12,1,2 as next three months , any links would be great. TIA
kamilacbe
14
Junior Poster in Training
Recommended Answers
Jump to PostIn JS months numbered from 0 to 11. Actually 11 is december. You can write simple function
function addMonths(d,n){ var dt=new Date(d.getTime()); dt.setMonth(dt.getMonth()+n); return dt; }
and then e.g.
var d=new Date(); // current date var d1=addMonths(d,1); var d2=addMonths(d,2); var d3=addMonths(d,3);
convert month number …
All 3 Replies
rproffitt
2,565
"Nothing to see here."
Moderator
AndrisP
193
Posting Pro in Training
Airshow
416
WiFi Lounge Lizard
Team Colleague
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.