그동안 일하면서 어떻게 달력이 필요 한 작업이 하나도 없었을까요??? 아이러니 하네요 ㅎㅎㅎ
방금 하나 만들어 봤는데 유효한지 모르겠네요~
[code]
/*
* "년, 월, 일"의 초기 값을 설정한다.(전달값이 있을경우 전달값 출력)
*/
$Year = ($_REQUEST['year'])?$_REQUEST['year']:date('Y');
$Month = ($_REQUEST['month'])?str_pad($_REQUEST['month'], 2, 0, STR_PAD_LEFT):date('m');
$Day = ($REQUEST['day'])?str_pad($_REQUEST['day'], 2, 0, STR_PAD_LEFT):date('d');
/*
* 초기 조건값
*/
$FirstDayWeek = date('w', strtotime($Year.$Month.'01')); // 1일은 몇 요일?
$LastDay = date('t', strtotime($Year.$Month.'01')); // 몇일까지 있니?
$PreLastDay = date('t', strtotime("-1 month", strtotime($Year.$Month.'01'))); // 지난달은 몇일 까지 있니?
$Day = $PreLastDay - $FirstDayWeek;
$HiddenDate = true;
?>
<div class="reservation">
<table class="calendar">
<thead>
<tr class="week">
<th scope="col">일요일</th>
<th scope="col">월요일</th>
<th scope="col">화요일</th>
<th scope="col">수요일</th>
<th scope="col">목요일</th>
<th scope="col">금요일</th>
<th scope="col">토요일</th>
</tr>
</thead>
<tbody class="mon">
<?php for($m=1; $m<7; $m++) { ?>
<tr>
<?php
for($w=0; $w<7; $w++) {
if($Day >= $PreLastDay) {
$HiddenDate = false;
$Day = 0;
$PreLastDay = $LastDay;
$FullDate = '';
}
$Day++; // day 증가
$FullDate = $Year.'-'.str_pad($Month, 2, 0, STR_PAD_LEFT).'-'.str_pad($Day, 2, 0, STR_PAD_LEFT);
if($HiddenDate || date('w', strtotime($FullDate)) <> $w) {
$FullDate = '';
$HiddenDate = true;
}
?>
<td>
<div><strong>날짜:</strong> <?php echo $Day; ?></div>
<div><strong>년.월.일:</strong> <?php echo ($FullDate)?$FullDate:'해당없음'; ?></div>
<div><strong>당월에 포함된 날짜인지 판단:</strong> <?php echo ($HiddenDate)?'미포함':'포함'; ?></div>
</td>
<?php } ?>
</tr>
<?php } ?>
</tbody>
</table>
</div>
[/code]
댓글 2개
bamchi
11년 전
고생하셨습니다. ㅎㅎ
Terrorboy
11년 전
실제 사용 해본결과 문제가 없네요 ^^
[http://sir.co.kr/data/cheditor4/1407/b78d5034adcef6e421f2c138865330d6_1404884563_4885.png]
[http://sir.co.kr/data/cheditor4/1407/b78d5034adcef6e421f2c138865330d6_1404884563_4885.png]
게시판 목록
프로그램
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 30 |
아우겐나이스
|
21년 전 | 4035 | |
| 29 |
아우겐나이스
|
21년 전 | 4431 | |
| 28 |
아우겐나이스
|
21년 전 | 3454 | |
| 27 | 21년 전 | 5816 | ||
| 26 | 21년 전 | 3088 | ||
| 25 | 21년 전 | 6068 | ||
| 24 | 18년 전 | 3642 | ||
| 23 | 21년 전 | 3628 | ||
| 22 | 21년 전 | 4238 | ||
| 21 | 21년 전 | 3811 | ||
| 20 | 21년 전 | 4210 | ||
| 19 | 21년 전 | 6670 | ||
| 18 | 21년 전 | 4728 | ||
| 17 | 21년 전 | 6973 | ||
| 16 | 21년 전 | 4163 | ||
| 15 | 21년 전 | 2618 | ||
| 14 | 21년 전 | 4961 | ||
| 13 | 21년 전 | 3393 | ||
| 12 |
Recluse
|
21년 전 | 3865 | |
| 11 |
아우겐나이스
|
21년 전 | 3560 | |
| 10 |
Recluse
|
21년 전 | 3387 | |
| 9 | 21년 전 | 3969 | ||
| 8 | 21년 전 | 5154 | ||
| 7 | 21년 전 | 4753 | ||
| 6 | 21년 전 | 5667 | ||
| 5 | 21년 전 | 4104 | ||
| 4 | 21년 전 | 4824 | ||
| 3 | 21년 전 | 4733 | ||
| 2 | 21년 전 | 3231 | ||
| 1 | 22년 전 | 4333 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기