오늘날짜 + 몇일 = 해당날짜
페이지 정보
작성자 서방님 댓글 2건 조회 131회 작성일 07-02-23 11:30본문
강좌 수강기간 연장시...
<script language="javascript">
<!--
function CloseDay()
{
DaysToAdd = document.getElementById("plus_day").value;
var startdate = new Date(Sell.yy1.value,Sell.mm1.value-1,Sell.dd1.value,Sell.hh1.value,Sell.ii1.value);
var newdate = new Date();
var newtimems = Math.floor(startdate.getTime() + (DaysToAdd * 24 * 60 * 60 * 1000));
newdate.setTime(newtimems);
Sell.yy2.value = newdate.getFullYear();
if ( String(newdate.getMonth()+1).length < 2 )
{
Sell.mm2.value = "0" + String(newdate.getMonth()+1) ;
}
else
{
Sell.mm2.value = newdate.getMonth()+1;
}
if ( String(newdate.getDate()).length < 2 )
{
Sell.dd2.value = "0" + String(newdate.getDate()) ;
}
else
{
Sell.dd2.value = newdate.getDate();
}
if ( String(newdate.getHours()).length < 2 )
{
Sell.hh2.value = "0" + String(newdate.getHours()) ;
}
else
{
Sell.hh2.value = newdate.getHours();
}
if ( String(newdate.getMinutes()).length < 2 )
{
Sell.ii2.value = "0" + String(newdate.getMinutes()) ;
} else
{
Sell.ii2.value = newdate.getMinutes();
}
return false;
}
//-->
</script>
<form name="Sell" method="post" action="">
시작년도 : <input type="text" name="yy1" value="2007"><br>
시작월 : <input type="text" name="mm1" value="02"><br>
시작일 : <input type="text" name="dd1" value="23"><br>
시작시간 : <input type="text" name="hh1" value="11"><br>
시작분 : <input type="text" name="ii1" value="20"><br><br>
추가날짜 : <input type="text" name="plus_day"><br><br>
<input type="button" value="계산하기" OnClick="CloseDay();"><br><br>
종료년도 : <input type="text" name="yy2" value=""><br>
종료월 : <input type="text" name="mm2" value=""><br>
종료일 : <input type="text" name="dd2" value=""><br>
종료시간 : <input type="text" name="hh2" value=""><br>
종료분 : <input type="text" name="ii2" value=""><br>
</form>
댓글목록
서방님님의 댓글
서방님 작성일월 부분에서 -1 해 주어야 같은 달이 됩니다. ^^
서방님님의 댓글
서방님 작성일
<P><FONT face=굴림>시간, 초 부분은 빼고 년도, 월, 일만..<BR><BR><BR><script language="javascript"><BR><!--<BR>function CloseDay()<BR>{<BR> if(document.getElementById("plus_day").value.length == 0) // 추가일이 입력되지 않았다면<BR> {<BR> alert("추가할 날수를 입력하십시오.");<BR> document.getElementById("plus_day").focus(); // 포커스<BR> return;<BR> }</FONT></P>
<P><FONT face=굴림> sDate = document.getElementById("sDate").value.split("/"); // 시작일을 슬래쉬를 기준으로 문자열 분리</FONT></P>
<P><FONT face=굴림> plus_day = document.getElementById("plus_day").value; // 추가일 받아오기</FONT></P>
<P><FONT face=굴림> var startdate = new Date(sDate[0], sDate[1]-1, sDate[2]); // 시작일 날짜 셋팅<BR> var newdate = new Date();</FONT></P>
<P><FONT face=굴림> var newtimems = Math.floor(startdate.getTime() + (plus_day * 24 * 60 * 60 * 1000));</FONT></P>
<P><FONT face=굴림> newdate.setTime(newtimems);</FONT></P>
<P><FONT face=굴림> eDate_year = newdate.getFullYear();</FONT></P>
<P><FONT face=굴림> if ( String(newdate.getMonth()+1).length < 2 )<BR> {<BR> eDate_month = "0" + String(newdate.getMonth()+1) ;<BR> }<BR> else<BR> {<BR> eDate_month = newdate.getMonth()+1;<BR> }</FONT></P>
<P><FONT face=굴림> if ( String(newdate.getDate()).length < 2 )<BR> {<BR> eDate_day = "0" + String(newdate.getDate()) ;<BR> }<BR> else<BR> {<BR> eDate_day = newdate.getDate();<BR> }</FONT></P>
<P><FONT face=굴림> document.getElementById("eDate").value = eDate_year + "/" + eDate_month + "/" + eDate_day;</FONT></P><FONT face=굴림>
<P><BR> return false;<BR>}<BR>//--><BR></script></P>
<P><form name="Sell" method="post" action=""><BR>시작일 : <input type="text" name="sDate" value="2007/02/23"><br></P>
<P>추가날짜 : <input type="text" name="plus_day"><br><br></P>
<P><input type="button" value="계산하기" OnClick="CloseDay();"><br><br></P>
<P>종료일 : <input type="text" name="eDate" value=""><br><BR></form></FONT></P>