이번달 달력(양력)을 표시하는 소스입니다. 조금만 응용하면 여러가지 모양이 나올 수 있겠죠!
<?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 님과 동감이라는.. ㅡ,.ㅡ
게시판 목록
프로그램
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 6630 |
차가운바람
|
12년 전 | 1169 | |
| 6629 | 12년 전 | 1168 | ||
| 6628 |
put777
|
12년 전 | 650 | |
| 6627 |
|
12년 전 | 703 | |
| 6626 | 12년 전 | 1618 | ||
| 6625 |
|
12년 전 | 727 | |
| 6624 |
미켈란젤로의왼손
|
12년 전 | 493 | |
| 6623 |
|
12년 전 | 1052 | |
| 6622 | 12년 전 | 1402 | ||
| 6621 |
차가운바람
|
12년 전 | 641 | |
| 6620 | 12년 전 | 743 | ||
| 6619 |
|
12년 전 | 979 | |
| 6618 | 12년 전 | 1751 | ||
| 6617 | 12년 전 | 646 | ||
| 6616 |
차가운바람
|
12년 전 | 904 | |
| 6615 | 12년 전 | 2858 | ||
| 6614 | 12년 전 | 623 | ||
| 6613 |
강명구베드로
|
12년 전 | 535 | |
| 6612 |
|
12년 전 | 430 | |
| 6611 | 12년 전 | 1214 | ||
| 6610 | 12년 전 | 1034 | ||
| 6609 | 12년 전 | 3685 | ||
| 6608 |
|
12년 전 | 835 | |
| 6607 | 12년 전 | 698 | ||
| 6606 | 12년 전 | 568 | ||
| 6605 | 12년 전 | 459 | ||
| 6604 | 12년 전 | 979 | ||
| 6603 |
geektoo
|
12년 전 | 710 | |
| 6602 | 12년 전 | 845 | ||
| 6601 | 12년 전 | 374 | ||
| 6600 | 12년 전 | 419 | ||
| 6599 | 12년 전 | 574 | ||
| 6598 | 12년 전 | 954 | ||
| 6597 | 12년 전 | 948 | ||
| 6596 | 12년 전 | 436 | ||
| 6595 | 12년 전 | 796 | ||
| 6594 | 12년 전 | 4577 | ||
| 6593 | 12년 전 | 2582 | ||
| 6592 | 12년 전 | 835 | ||
| 6591 | 12년 전 | 597 | ||
| 6590 |
|
12년 전 | 1407 | |
| 6589 | 12년 전 | 780 | ||
| 6588 |
GINUSSOFT
|
12년 전 | 5135 | |
| 6587 | 12년 전 | 6218 | ||
| 6586 | 12년 전 | 1053 | ||
| 6585 | 12년 전 | 815 | ||
| 6584 | 12년 전 | 474 | ||
| 6583 |
|
12년 전 | 986 | |
| 6582 | 12년 전 | 879 | ||
| 6581 | 12년 전 | 850 | ||
| 6580 | 12년 전 | 626 | ||
| 6579 |
알랑가몰라
|
12년 전 | 940 | |
| 6578 | 12년 전 | 1338 | ||
| 6577 | 12년 전 | 1510 | ||
| 6576 |
경dragon
|
12년 전 | 783 | |
| 6575 | 12년 전 | 1892 | ||
| 6574 | 12년 전 | 692 | ||
| 6573 | 12년 전 | 998 | ||
| 6572 |
|
12년 전 | 1677 | |
| 6571 |
CTOMAN
|
12년 전 | 1971 | |
| 6570 | 12년 전 | 1741 | ||
| 6569 | 12년 전 | 1899 | ||
| 6568 | 12년 전 | 2412 | ||
| 6567 | 12년 전 | 1037 | ||
| 6566 |
lainfox
|
12년 전 | 1540 | |
| 6565 | 12년 전 | 3663 | ||
| 6564 |
제주프라이스
|
12년 전 | 1543 | |
| 6563 | 12년 전 | 1576 | ||
| 6562 |
프로프리랜서
|
12년 전 | 1358 | |
| 6561 |
프로프리랜서
|
12년 전 | 980 | |
| 6560 |
프로프리랜서
|
12년 전 | 1237 | |
| 6559 |
프로프리랜서
|
12년 전 | 1148 | |
| 6558 |
프로프리랜서
|
12년 전 | 1364 | |
| 6557 |
프로프리랜서
|
12년 전 | 1987 | |
| 6556 |
프로프리랜서
|
12년 전 | 1531 | |
| 6555 |
프로프리랜서
|
12년 전 | 1375 | |
| 6554 |
프로프리랜서
|
12년 전 | 3897 | |
| 6553 |
프로프리랜서
|
12년 전 | 1522 | |
| 6552 | 12년 전 | 858 | ||
| 6551 |
왕초보sasa
|
12년 전 | 1550 | |
| 6550 |
왕초보sasa
|
12년 전 | 645 | |
| 6549 |
왕초보sasa
|
12년 전 | 917 | |
| 6548 | 12년 전 | 1306 | ||
| 6547 | 12년 전 | 1205 | ||
| 6546 | 12년 전 | 5170 | ||
| 6545 | 12년 전 | 2527 | ||
| 6544 |
AnnieK
|
12년 전 | 1792 | |
| 6543 |
베르무트7
|
12년 전 | 655 | |
| 6542 |
오늘도망했다
|
12년 전 | 2242 | |
| 6541 | 12년 전 | 823 | ||
| 6540 | 12년 전 | 1147 | ||
| 6539 | 12년 전 | 856 | ||
| 6538 |
senseme
|
12년 전 | 3383 | |
| 6537 | 12년 전 | 783 | ||
| 6536 | 12년 전 | 3673 | ||
| 6535 | 12년 전 | 1360 | ||
| 6534 | 12년 전 | 1630 | ||
| 6533 | 12년 전 | 2255 | ||
| 6532 |
냐옹이사범
|
12년 전 | 2314 | |
| 6531 | 12년 전 | 575 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기