반응형
- 현재부터 12개월 기간의 연월 계산
function monthChk(){
var today = new Date(); //객체 생성
var year = today.getFullYear(); //현재 해
var month = today.getMonth() + 1; //현재 월 0~11 +1
var p1 = year+""+month; //'0'이 붙지않는 숫자의 경우 숫자간의 합산문제 발생 -> 문자화 +""+를 추가
var p2 = year+""+month_calc(month+1);
var p3 = year+""+month_calc(month+2);
var p4 = year+""+month_calc(month+3);
var p5 = year+""+month_calc(month+4);
var p6 = year+""+month_calc(month+5);
var p7 = year+""+month_calc(month+6);
var p8 = year+""+month_calc(month+7);
var p9 = year+""+month_calc(month+8);
var p10 = year+""+month_calc(month+9);
var p11 = year+""+month_calc(month+10);
var p12 = year+""+month_calc(month+11);
}
function month_calc(n){
m = n%12 //12로 나눈 나머지
if(m < 10)
m = m < 10 ? '0' + m : m; //10보다 작을 경우 앞에 '0'을 추가
return m;
}
반응형
'JSP > JSP' 카테고리의 다른 글
[JSP] 창(window)크기 설정 (0) | 2019.11.07 |
---|---|
[JSP] selectbox option disabled (0) | 2019.11.06 |
[JSP] replace매서드 - String에 위치한 모든문자 변경 (0) | 2019.11.06 |
[JSP] 톰캣(tomcat)서버 timed out 에러 (0) | 2019.11.06 |
[JSP] tomcat 서버 설정 (0) | 2019.11.06 |