인터넷정보

날짜 시작일~종료일 출력

알 수 없는 사용자 2007. 10. 13. 15:52

<script language="javascript">
    var inDay = "2006-04-03";
    var inSp = inDay.split("-");
    var newinD = new Date(inSp[0], inSp[1] - 1, inSp[2]);
    var inDTimeS = newinD.valueOf();

    var outDay = "2006-04-07";
    var outSp = outDay.split("-");
    var newoutD = new Date(outSp[0], outSp[1] - 1, outSp[2]);
    var outDTimeS = newoutD.valueOf();

    var dayCnt = (outDTimeS - inDTimeS)/(60*60*24*1000);

    var loopDate = new Array();

    for(i=0;i<=dayCnt;i++){
        var arrTimeS = inDTimeS + (i*60*60*24*1000);
        var arrDate = new Date(arrTimeS);
        var loopY = arrDate.getYear();
        var loopM = arrDate.getMonth()+1;
        var loopD = arrDate.getDate();

        if((""+loopM).length==1) loopM = "0"+loopM;
        if((""+loopD).length==1) loopD = "0"+loopD;
       
        loopDate[i] = loopY+"-"+loopM+"-"+loopD;
    }

    for(i=0;i<loopDate.length;i++){
        document.write(loopDate[i]+"<br>");
    }
</script>


반응형