// 오늘 날짜 구하기
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];
}

Posted by ladon
,