JavaScript
[JavaScript] 다음달 1일과 마지막일 가져오기
Sort
2013. 2. 18. 15:43
function monthPlus( date, gubn ) {
var endDay = new Array(31,28,31,30,31,30,31,31,30,31,30,31);
var now = new Date();
var day;
var p_date = date.split("/").join("");
if( gubn == "S") {
day = "01";
}else {
day = endDay[ (now.getMonth()+1) ];
}
if( parseInt(p_date.substr(4,2), 10) == 12 ) {
p_date = (parseInt(p_date.substring(0,4), 10) + 1) + "01" + day;
}else {
p_date = p_date.substr(0,4) + leadingZeros(parseInt(p_date.substr(4,2),10) +1, 2) + day;
}
return p_date;
}