T

프로그래머가 되고 나서 처음으로 달력을 짜보았습니다.

그동안 일하면서 어떻게 달력이 필요 한 작업이 하나도 없었을까요??? 아이러니 하네요 ㅎㅎㅎ

방금 하나 만들어 봤는데 유효한지 모르겠네요~


[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]
|
댓글을 작성하시려면 로그인이 필요합니다.

프로그램

8,188건
+
제목 글쓴이 날짜 조회
16-03-02 조회 3,239
16-01-19 조회 2,526
15-12-23 조회 2,959
15-12-08 조회 3,674
14-10-30 조회 5,732
14-06-06 조회 5,555
12-08-30 조회 3,910
12-08-20 조회 3,828
12-07-15 조회 5,158
12-07-13 조회 3,630
12-07-06 조회 3,858
12-06-27 조회 3,366
12-06-23 조회 3,569
12-05-03 조회 5,181
12-04-20 조회 4,125
12-03-29 조회 4,632
12-03-22 조회 4,725
12-03-22 조회 3,510
12-03-21 조회 3,282
12-03-11 조회 3,715
12-03-06 조회 4,263
12-02-22 조회 4,532
12-02-17 조회 3,329
12-02-17 조회 6,179
12-02-14 조회 6,135
12-02-06 조회 4,261
12-01-18 조회 3,215
12-01-06 조회 3,443
11-12-30 조회 3,913
11-12-30 조회 7,058
11-12-21 조회 3,280
11-12-21 조회 4,245
11-12-16 조회 3,273
11-12-15 조회 3,323
11-12-15 조회 3,422
11-12-15 조회 4,223
11-12-09 조회 3,227
11-12-09 조회 3,308
11-12-07 조회 2,874
11-12-07 조회 3,960
11-12-05 조회 4,417
11-12-02 조회 3,861
11-12-01 조회 2,731
11-12-01 조회 2,776
11-12-01 조회 2,762