티스토리 뷰

반응형

원하는 달의 마지막날 구하기

var last_day = new Date(e.date);      
var last_year = last_day.getFullYear();
var last_month = last_day.getMonth()+1;          
last_day = ( new Date( last_year, last_month, 0) ).getDate();

 

날짜 빼기, 더하기 (-,+ 변경하면 됨!)

var last_day = new Date(e.date);  
last_day.setDate(last_day.getDate()+6);       
var last_year = last_day.getFullYear().toString();
var last_month = last_day.getMonth()+1;   
var last_date = last_day.getDate();
if(last_month<10){last_month='0'+last_month} 
if(last_date<10){last_date='0'+last_date} 
      
last_day = last_year+last_month+last_date;

반응형