자바스크립트 날짜 더하기 함수
마스터욱
0
21
0
0
2019-07-30 16:27:27
function addDay(ymd, v_day)
{
var yyyy = ymd.substr(0,4);
var mm = eval(ymd.substr(4,2) + "- 1") ;
var dd = ymd.substr(6,2);
var dt3 = new Date(yyyy, mm, eval(dd + '+' + v_day));
yyyy = dt3.getFullYear();
mm = (dt3.getMonth()+1)<10? "0" + (dt3.getMonth()+1) : (dt3.getMonth()+1) ;
dd = dt3.getDate()<10 ? "0" + dt3.getDate() : dt3.getDate();
return "" + yyyy + "" + mm + "" + dd ;
}
addDay('20101205', 5);
=> 20101210