이번달 달력(양력)을 표시하는 소스입니다. 조금만 응용하면 여러가지 모양이 나올 수 있겠죠!
<?php
// 지정한 년,월의 총 일수를 구한다.
function cal_days_in_month($month, $year) {
return $month == 2 ? ($year % 4 ? 28 : ($year % 100 ? 29 : ($year % 400 ? 28 : 29))) : (($month - 1) % 7 % 2 ? 30 : 31);
}
?>
<?php
$date_month = date("m"); //오늘이 속한 월(1,2,3...12)
$date_year = date("Y"); //오늘이 속한 년(...2003,2004,2005...)
$t_days = cal_days_in_month($date_month, $date_year); //지정한 년,월의 총 일수(28,29,30,31)
$day = date("w", mktime(0, 0, 0, $date_month, 1, $date_year)); //0(일요일)부터 6(토요일)
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=euc-kr">
<title>달력</title>
<style type=text/css>
td { font-size:12px; font-family:돋움체; color:#7D7D7D; line-height:1.2; }
th { font-size:13px; font-family:돋움체; color:#000000; line-height:1.5; }
.today { font-size:12px; font-family:돋움체; color:#000000; background:#C4E1FF line-height:1.2; }
</style>
</head>
<body bgcolor=#FFFFFF>
<table border="0" bgcolor="#F2F2F2" cellpadding="2" cellspacing="2">
<tr><th colspan="7"><?php echo $date_year."년 ".$date_month."월"; ?></th></tr>
<tr bgcolor="#C0C0C0"><th><font color="#FF0000">일</font></th><th>월</th><th>화</th><th>수</th>
<th>목</th><th>금</th><th><font color="#0000FF">토</font></th></tr>
<?php
for ($i = 0; $i <= $t_days; $i++) {
if ($day > 6) {
echo "</tr>\n<tr>\n";
$day = 0;
}
if ($i == date("j")) { ?>
<td align="right" class="today"><?php echo $i; $day++; echo "</td>\n";
}
else if ($i > 0) { ?>
<td align="right"><?php echo $i; $day++; echo "</td>\n";
}
else if ($day > 0) { ?>
<tr><td colspan="<?php echo $day; ?>"><?php echo "</td>\n";
}
if ($i == $t_days && $day < 6) { ?>
<td colspan="<?php echo 7 - $day; ?>"><?php echo "</td>\n</tr>\n";
}
}
?>
</table>
</body>
</html><div class='small'>[이 게시물은 관리자님에 의해 2011-10-31 17:12:10 PHP & HTML에서 이동 됨]</div>
<?php
// 지정한 년,월의 총 일수를 구한다.
function cal_days_in_month($month, $year) {
return $month == 2 ? ($year % 4 ? 28 : ($year % 100 ? 29 : ($year % 400 ? 28 : 29))) : (($month - 1) % 7 % 2 ? 30 : 31);
}
?>
<?php
$date_month = date("m"); //오늘이 속한 월(1,2,3...12)
$date_year = date("Y"); //오늘이 속한 년(...2003,2004,2005...)
$t_days = cal_days_in_month($date_month, $date_year); //지정한 년,월의 총 일수(28,29,30,31)
$day = date("w", mktime(0, 0, 0, $date_month, 1, $date_year)); //0(일요일)부터 6(토요일)
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=euc-kr">
<title>달력</title>
<style type=text/css>
td { font-size:12px; font-family:돋움체; color:#7D7D7D; line-height:1.2; }
th { font-size:13px; font-family:돋움체; color:#000000; line-height:1.5; }
.today { font-size:12px; font-family:돋움체; color:#000000; background:#C4E1FF line-height:1.2; }
</style>
</head>
<body bgcolor=#FFFFFF>
<table border="0" bgcolor="#F2F2F2" cellpadding="2" cellspacing="2">
<tr><th colspan="7"><?php echo $date_year."년 ".$date_month."월"; ?></th></tr>
<tr bgcolor="#C0C0C0"><th><font color="#FF0000">일</font></th><th>월</th><th>화</th><th>수</th>
<th>목</th><th>금</th><th><font color="#0000FF">토</font></th></tr>
<?php
for ($i = 0; $i <= $t_days; $i++) {
if ($day > 6) {
echo "</tr>\n<tr>\n";
$day = 0;
}
if ($i == date("j")) { ?>
<td align="right" class="today"><?php echo $i; $day++; echo "</td>\n";
}
else if ($i > 0) { ?>
<td align="right"><?php echo $i; $day++; echo "</td>\n";
}
else if ($day > 0) { ?>
<tr><td colspan="<?php echo $day; ?>"><?php echo "</td>\n";
}
if ($i == $t_days && $day < 6) { ?>
<td colspan="<?php echo 7 - $day; ?>"><?php echo "</td>\n</tr>\n";
}
}
?>
</table>
</body>
</html><div class='small'>[이 게시물은 관리자님에 의해 2011-10-31 17:12:10 PHP & HTML에서 이동 됨]</div>
댓글 2개
wrappin
20년 전
line4
return $month == 2 ? ($year % 4 ? 28 : ($year % 100 ? 29 : ($year % 400 ? 28 : 29))) : (($month - 1) % 7 % 2 ? 30 : 31);} 여서 에러가 나는 이유가 궁금 합니다.. 원인을 못찾게다는.
return $month == 2 ? ($year % 4 ? 28 : ($year % 100 ? 29 : ($year % 400 ? 28 : 29))) : (($month - 1) % 7 % 2 ? 30 : 31);} 여서 에러가 나는 이유가 궁금 합니다.. 원인을 못찾게다는.
사랑과우정
18년 전
wrappin 님과 동감이라는.. ㅡ,.ㅡ
게시판 목록
프로그램
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 8130 | 9년 전 | 527 | ||
| 8129 |
|
9년 전 | 658 | |
| 8128 | 9년 전 | 522 | ||
| 8127 |
|
9년 전 | 580 | |
| 8126 | 9년 전 | 511 | ||
| 8125 | 9년 전 | 774 | ||
| 8124 |
|
9년 전 | 529 | |
| 8123 | 9년 전 | 512 | ||
| 8122 | 9년 전 | 440 | ||
| 8121 | 9년 전 | 550 | ||
| 8120 | 9년 전 | 473 | ||
| 8119 | 9년 전 | 556 | ||
| 8118 |
|
9년 전 | 639 | |
| 8117 |
|
9년 전 | 410 | |
| 8116 |
PASKRAN
|
9년 전 | 472 | |
| 8115 | 9년 전 | 461 | ||
| 8114 |
kiplayer
|
9년 전 | 601 | |
| 8113 | 9년 전 | 456 | ||
| 8112 |
|
9년 전 | 563 | |
| 8111 | 9년 전 | 412 | ||
| 8110 | 9년 전 | 448 | ||
| 8109 | 9년 전 | 382 | ||
| 8108 |
|
9년 전 | 550 | |
| 8107 |
|
9년 전 | 444 | |
| 8106 |
|
9년 전 | 446 | |
| 8105 | 9년 전 | 479 | ||
| 8104 |
|
9년 전 | 443 | |
| 8103 |
|
9년 전 | 441 | |
| 8102 |
|
9년 전 | 411 | |
| 8101 |
snshero
|
9년 전 | 798 | |
| 8100 | 9년 전 | 848 | ||
| 8099 | 9년 전 | 819 | ||
| 8098 | 9년 전 | 718 | ||
| 8097 | 9년 전 | 525 | ||
| 8096 | 9년 전 | 722 | ||
| 8095 | 9년 전 | 854 | ||
| 8094 | 9년 전 | 524 | ||
| 8093 | 9년 전 | 810 | ||
| 8092 | 9년 전 | 763 | ||
| 8091 | 9년 전 | 1149 | ||
| 8090 | 9년 전 | 776 | ||
| 8089 | 9년 전 | 983 | ||
| 8088 | 9년 전 | 655 | ||
| 8087 | 9년 전 | 776 | ||
| 8086 | 9년 전 | 528 | ||
| 8085 | 9년 전 | 495 | ||
| 8084 | 9년 전 | 615 | ||
| 8083 | 9년 전 | 583 | ||
| 8082 | 9년 전 | 767 | ||
| 8081 | 9년 전 | 475 | ||
| 8080 | 9년 전 | 576 | ||
| 8079 | 9년 전 | 535 | ||
| 8078 | 9년 전 | 456 | ||
| 8077 | 9년 전 | 542 | ||
| 8076 | 9년 전 | 417 | ||
| 8075 | 9년 전 | 450 | ||
| 8074 | 9년 전 | 409 | ||
| 8073 | 9년 전 | 464 | ||
| 8072 | 9년 전 | 459 | ||
| 8071 |
o1o111
|
9년 전 | 906 | |
| 8070 | 9년 전 | 413 | ||
| 8069 | 9년 전 | 348 | ||
| 8068 | 9년 전 | 602 | ||
| 8067 | 9년 전 | 401 | ||
| 8066 | 9년 전 | 432 | ||
| 8065 | 9년 전 | 393 | ||
| 8064 | 9년 전 | 376 | ||
| 8063 | 9년 전 | 347 | ||
| 8062 | 9년 전 | 314 | ||
| 8061 | 9년 전 | 358 | ||
| 8060 | 9년 전 | 399 | ||
| 8059 | 9년 전 | 337 | ||
| 8058 | 9년 전 | 263 | ||
| 8057 | 9년 전 | 396 | ||
| 8056 | 9년 전 | 315 | ||
| 8055 | 9년 전 | 362 | ||
| 8054 | 9년 전 | 372 | ||
| 8053 | 9년 전 | 419 | ||
| 8052 | 9년 전 | 297 | ||
| 8051 | 9년 전 | 341 | ||
| 8050 | 9년 전 | 398 | ||
| 8049 | 9년 전 | 333 | ||
| 8048 | 9년 전 | 442 | ||
| 8047 | 9년 전 | 374 | ||
| 8046 | 9년 전 | 320 | ||
| 8045 | 9년 전 | 271 | ||
| 8044 | 9년 전 | 352 | ||
| 8043 | 9년 전 | 302 | ||
| 8042 | 9년 전 | 302 | ||
| 8041 | 9년 전 | 362 | ||
| 8040 | 9년 전 | 286 | ||
| 8039 | 9년 전 | 325 | ||
| 8038 | 9년 전 | 275 | ||
| 8037 | 9년 전 | 414 | ||
| 8036 | 9년 전 | 497 | ||
| 8035 | 9년 전 | 442 | ||
| 8034 | 9년 전 | 398 | ||
| 8033 | 9년 전 | 358 | ||
| 8032 | 9년 전 | 456 | ||
| 8031 | 9년 전 | 360 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기