2012-07-04 93 views

回答

3

這是你如何能做到這一點...

獲取最後一天,對於給定的年份和月份:

function getLastDayOfYearAndMonth(year, month) 
{ 
    return(new Date((new Date(year, month + 1, 1)) - 1)).getDate(); 
} 

如果您需要了解的日期是上個月一天beforeShowDay事件:

$('.selector').datepicker(
{ 
    beforeShowDay: function(date) 
    { 
     // getDate() returns the day [ 0 to 31 ] 
     if (date.getDate() == 
      getLastDayOfYearAndMonth(date.getFullYear(), date.getMonth())) 
     { 
      return [true, '']; 
     } 

     return [false, '']; 
    } 
}); 
+0

非常感謝! – XTN

+0

這工作完美!謝謝 – ScottyG

相關問題