2026년 10월 24일 토요일
미단재

팁앤텍 작은 달력 표시하기

작성자 user 작성일 2002-08-29 04:15:58 조회수 563
<?php
//* calendar 용..

//표시하고자 하는 월 값 초기화
$cur_date = isset($cur_date) ? strtotime($cur_date) : time();

//요일의 시작을 설정(일요일이면 0, 월요일이면 1)
$start_dayofweak = 0;//0-sunday , 1-monday

//달력정보 : 달력에서 표시하는 첫날과 마지막날의 정보
$calendar = getCalendarInfo($cur_date,$start_dayofweak);
$day_term = 60*60*24;

//전월과 다음월 : 링크위해 사용
$before_cur_date = date("Y-m-d",mktime(0,0,0,date("m",$cur_date)-1,1,date("Y",$cur_date)));
$next_cur_date = date("Y-m-d",mktime(0,0,0,date("m",$cur_date)+1,1,date("Y",$cur_date)));

echo "
".strftime('%B, %Y',$cur_date)."
<  
>
".substr(date("l",intval($calendar[startdate]+$i*$day_term)),0,1)."
";

//출력
if(!$_disp_month):
$date_str = date("m/d",$display_date);
$_disp_month = true;
else:
if(intval(date("d",$display_date)) == 1) {
$date_str = date("m/d",$display_date);
} else {
$date_str = date("d",$display_date);
}
endif;

echo sprintf("%s
%s%s%s",(($_cnt%7 == 0) ? "" : ""));

if($display_date==$calendar[enddate]) break;

$_cnt++;
}


//* 해당월 달력정보
function getCalendarInfo($date,$start_dayofweak = 0){

$_date = is_numeric($date) ? $date : strtotime($date);

$info = array();
//그달의 첫날
$info[firstdate] = mktime(0,0,0,date("m",$_date),1,date("Y",$_date));
//그달의 마지막날
$info[lastdate] = mktime(0,0,0,date("m",$_date)+1,0,date("Y",$_date));
//달력시작일
$info[startdate] = $info[firstdate] + 60*60*24*intval($start_dayofweak-strftime("%w",$info[firstdate]));
//달력종료일
$info[enddate] = $info[lastdate] + 60*60*24*intval($start_dayofweak-strftime("%w",$info[lastdate])+6);
return $info;
}
?>

댓글 0개