// 오늘 날짜 구하기
function getDay(){
var today = new Date();
var ty = today.getFullYear();
var tm = today.getMonth()+1;
var td = today.getDate();
if(tm < 10) {
tm = "0"+tm;
}
if(td < 10) {
td = "0"+td;
}
var todayValue = ty+"-"+tm+"-"+td
}
// 어제 날짜를 구할때는
var yesterday = new Date(today.valueOf()-(24*60*60*1000));
해서 오늘날짜랑 똑같이 계산하면 됨
// 특정일 에 대한 요일 구하기
function getWeek(strsDate){
var weekName = new Array("일", "월", "화", "수", "목", "금", "토");
var strYear = "";
var strMonth = "";
var strDay = "";
var aDate = null;
if( strsDate.indexOf("-") > 0){
aDate = strsDate.split("-");
strYear = aDate[0];
strMonth = aDate[1];
strDay = aDate[2];
} else {
strYear = strsDate.slice(0,4);
strMonth = strsDate.slice(4,6);
strDay = strDate.slice(6,8);
}
strDay = parseFloat(strDay);
var sDate = strYear + "/" + strMonth + "/" + strDay;
var tmpDate = new Date(sDate);
var nWeek = tmpDate.getDay();
document.forms[0].weekNameValue.value = weekName[nWeek];
}
'개발 > WEB' 카테고리의 다른 글
이클립스 에러 문제해결 (참고만) (0) | 2016.01.05 |
---|---|
javascript 페이지 리플래시 (0) | 2011.08.10 |
HTML input 외형 숨기기, 커서 손가락 모양 (0) | 2011.08.10 |
DIV 나눠 스크롤 걸기(화면 중간 스크롤 걸때) (0) | 2009.09.24 |
ALERT 창이 두번씩 찍히는 경우~ (두번 실행되는 경우) (0) | 2009.09.16 |