how to get the days of 2,3,4 months in javascript -


i want days of more 1 month if pass 2 , 3 ,4 number of month function, want total number of days today

function get_days_in_month(months){    days_in_month = new date();    var y = days_in_month.getfullyear();    var m = days_in_month.getmonth();    if(months==1){       return new date(y,m+1,0).getdate();    }   if(months==2){     // need write code or other logic   }  } 

thanks in advance

use for loop:

var total = 0;  (i = 1; <= months; i++) {     total += new date(y, m + i, 0).getdate(); }  return total; 

jsfiddle demo.


Comments

Popular posts from this blog

c++ - OpenCV Error: Assertion failed <scn == 3 ::scn == 4> in unknown function, -

php - render data via PDO::FETCH_FUNC vs loop -

The canvas has been tainted by cross-origin data in chrome only -