검색결과 리스트
dateadd에 해당되는 글 2건
- 2012.07.31 [Javascript] VBScript DateAdd 함수 구현
- 2012.07.14 [Javascript] DateAdd
글
/**
*
* @param interval : yyyy(년), m(월), d(일)
* @param number : 증가 년, 월, 일
* @param dateformat : 날짜 문자열
* @returns {String} yyyymmdd 8자리로 리턴
*/
function DateAdd(interval, number, dateformat) {
dateformat = clear_DateSTRING(dateformat);
var int_millisecond = 1;
var int_second = 1000 * int_millisecond;
var int_minute = 60 * int_second;
var int_hour = 60 * int_minute;
var int_day = 24 * int_hour;
var YY_form = CInt(Left(dateformat, 4));
var MM_form = CInt(Mid(dateformat, 5, 2))-1;
var DD_form = CInt(Right(dateformat, 2));
var date = new Date(YY_form, MM_form, DD_form);
var date_milliseconds = date.valueOf();
var add_milliseconds = 0;
var ret_date = null;
switch (interval) {
case "yyyy":
date.setFullYear(date.getFullYear()+number, date.getMonth(), date.getDate());
ret_date = date;
break;
case "m":
date.setFullYear(date.getFullYear(), date.getMonth()+number, date.getDate());
ret_date = date;
break;
case "d":
add_milliseconds = number * int_day;
ret_date = new Date(date_milliseconds + add_milliseconds);
break;
}
var year = ret_date.getFullYear();
var month = ret_date.getMonth() + 1;
if ( month < 10 ) {
month = "0" + month;
}
var day = ret_date.getDate();
if ( day < 10 ) {
day = "0" + day;
}
return ( "" + year + month + day );
}
'JavaScript > JavaScript' 카테고리의 다른 글
[javascript] 자바스크립트의 true, false (0) | 2012.08.30 |
---|---|
[javascript] 이벤트 브라우져 호환성 (0) | 2012.08.28 |
[Javascript] 자바스크립트 Global Properties and Functions (0) | 2012.07.31 |
[JavaScript] IE 메모리 릭 찾기 (0) | 2012.07.27 |
[javascript] 동적으로 .js 파일을 인클루드 하는 함수 (0) | 2012.07.26 |
트랙백
댓글
글
// 예 add_DATEs("2012-12-31", 3) 이면 2013-01-03을 리턴 function add_DATEs(dateformat, dates) { dateformat = clear_DateSTRING(dateformat); var int_millisecond = 1; var int_second = 1000 * int_millisecond; var int_minute = 60 * int_second; var int_hour = 60 * int_minute; var int_day = 24 * int_hour; var YY_form = CInt(Left(dateformat, 4)); var MM_form = CInt(Mid(dateformat, 5, 2))-1; var DD_form = CInt(Right(dateformat, 2)); var date = new Date(YY_form, MM_form, DD_form); var date_milliseconds = date.valueOf(); var add_milliseconds = dates * int_day; var ret_date = new Date(date_milliseconds + add_milliseconds); var year = ret_date.getFullYear(); var month = ret_date.getMonth() + 1; if ( month < 10 ) { month = "0" + month; } var day = ret_date.getDate(); if ( day < 10 ) { day = "0" + day; } return ( "" + year + month + day ); }
'JavaScript > JavaScript' 카테고리의 다른 글
[JavaScript] 선언과 할당의 미묘한 차이가 런타임시 에러를 발생시킨다. (0) | 2012.07.15 |
---|---|
[JavaScript] undefiend와 null 차이 (0) | 2012.07.15 |
[javascript] Regex 탐욕적 수량자, 게으른 수량자 (0) | 2012.07.06 |
[Javascript] namespace 패턴 (0) | 2012.06.30 |
[javascript] submitWithJson (동적으로 폼서브밋 하기) (0) | 2012.02.21 |
RECENT COMMENT