Post
KO

자바스크립트 날짜 계산

자바스크립트 날짜 계산

    <%         Date aaa = new java.sql.Date((new java.util.Date()).getTime());     %>

스크립트릿을 이용하여 현재 시간을 가져온뒤 자바스크립트 변수에 넣고

아래와 같이 한달 계산 하는 거 만듬

   

            alert(addOneMonth(new Date(bbb)));

        }         function addOneMonth(date){             var newDate = new Date(date);             newDate.setDate(newDate.getDate()+30);             return converDateString(newDate);         }

        function converDateString(dt){             return dt.getFullYear() + “-“ + addZero(eval(dt.getMonth()+1)) + “-“ + addZero(dt.getDate());         }

        function addZero(i){             var rtn = i + 100;             return rtn.toString().substring(1,3);         }

참고 :  http://findfun.tistory.com/395

This article is licensed under CC BY 4.0 by the author.