검색결과 리스트
글
// 예 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