js의 날짜 컨트롤 간단한 버전

1409 단어
        // 
        window.onload= function(){      
                datecontroller();}


        //2016-04-16 , 
        function datecontroller(){
                curdate = new Date(); 
                var curyear = "20"+(curdate.getYear()-100);
                var curmonth = curdate.getMonth()+1;// curmonth 
                var curdate = curdate.getDate();// curdate 
                if(0<curmonth && curmonth<10){
                        if(0<curdate && curdate<10){
                                showdate(curyear,"0"+curmonth,"0"+curdate);
                        }else{
                                showdate(curyear,"0"+curmonth,curdate);
                        }
                }else{
                        if(0<curdate && curdate<10){
                                showdate(curyear,curmonth,"0"+curdate);
                        }else{
                                showdate(curyear,curmonth,curdate);
                        }
                }
        }
        // 
        function showdate(curyear,curmonth,curdate){
                document.getElementById("checkindate").value = curyear+"-"+curmonth+"-"+curdate;
                document.getElementById("checkoutdate").value = curyear+"-"+curmonth+"-"+(curdate+1);   
        }

좋은 웹페이지 즐겨찾기