이번달 달력(양력)을 표시하는 소스입니다. 조금만 응용하면 여러가지 모양이 나올 수 있겠죠!
<?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 님과 동감이라는.. ㅡ,.ㅡ
게시판 목록
프로그램
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 6530 |
퍼블리셔강
|
12년 전 | 640 | |
| 6529 | 12년 전 | 1296 | ||
| 6528 | 12년 전 | 616 | ||
| 6527 | 12년 전 | 787 | ||
| 6526 | 12년 전 | 6576 | ||
| 6525 | 12년 전 | 548 | ||
| 6524 | 12년 전 | 832 | ||
| 6523 | 12년 전 | 479 | ||
| 6522 | 12년 전 | 525 | ||
| 6521 | 12년 전 | 794 | ||
| 6520 | 12년 전 | 729 | ||
| 6519 | 12년 전 | 1733 | ||
| 6518 |
가슴시린하늘
|
12년 전 | 1718 | |
| 6517 | 12년 전 | 1354 | ||
| 6516 | 12년 전 | 5222 | ||
| 6515 | 12년 전 | 1494 | ||
| 6514 | 12년 전 | 1594 | ||
| 6513 | 12년 전 | 945 | ||
| 6512 | 12년 전 | 1969 | ||
| 6511 | 12년 전 | 1365 | ||
| 6510 | 12년 전 | 3046 | ||
| 6509 |
프로프리랜서
|
12년 전 | 2545 | |
| 6508 |
프로프리랜서
|
12년 전 | 1894 | |
| 6507 |
프로프리랜서
|
12년 전 | 2369 | |
| 6506 |
프로프리랜서
|
12년 전 | 1850 | |
| 6505 |
프로프리랜서
|
12년 전 | 1628 | |
| 6504 | 12년 전 | 1017 | ||
| 6503 | 12년 전 | 1125 | ||
| 6502 |
프로프리랜서
|
12년 전 | 5550 | |
| 6501 |
프로프리랜서
|
12년 전 | 2593 | |
| 6500 |
프로프리랜서
|
12년 전 | 3075 | |
| 6499 |
프로프리랜서
|
12년 전 | 1745 | |
| 6498 |
프로프리랜서
|
12년 전 | 1459 | |
| 6497 | 12년 전 | 801 | ||
| 6496 |
yunkiri486
|
12년 전 | 1805 | |
| 6495 | 12년 전 | 911 | ||
| 6494 | 12년 전 | 1487 | ||
| 6493 | 12년 전 | 2756 | ||
| 6492 |
오늘도망했다
|
12년 전 | 2331 | |
| 6491 |
오늘도망했다
|
12년 전 | 1676 | |
| 6490 |
오늘도망했다
|
12년 전 | 6654 | |
| 6489 |
오늘도망했다
|
12년 전 | 2491 | |
| 6488 |
홈피119
|
12년 전 | 696 | |
| 6487 | 12년 전 | 656 | ||
| 6486 | 12년 전 | 1402 | ||
| 6485 | 12년 전 | 2047 | ||
| 6484 | 12년 전 | 894 | ||
| 6483 | 12년 전 | 696 | ||
| 6482 | 12년 전 | 1329 | ||
| 6481 | 12년 전 | 1461 | ||
| 6480 |
Header
|
12년 전 | 686 | |
| 6479 |
|
12년 전 | 1121 | |
| 6478 |
개초보제이
|
12년 전 | 1388 | |
| 6477 | 12년 전 | 779 | ||
| 6476 | 12년 전 | 1071 | ||
| 6475 | 12년 전 | 3664 | ||
| 6474 | 12년 전 | 1415 | ||
| 6473 | 12년 전 | 958 | ||
| 6472 | 12년 전 | 838 | ||
| 6471 |
AMDbest
|
12년 전 | 1201 | |
| 6470 |
jinmuk
|
12년 전 | 1440 | |
| 6469 |
jinmuk
|
12년 전 | 4241 | |
| 6468 |
jinmuk
|
12년 전 | 5565 | |
| 6467 | 12년 전 | 685 | ||
| 6466 |
jinmuk
|
12년 전 | 2259 | |
| 6465 |
jinmuk
|
12년 전 | 6727 | |
| 6464 |
jinmuk
|
12년 전 | 2402 | |
| 6463 |
jinmuk
|
12년 전 | 9318 | |
| 6462 |
희망과열정
|
12년 전 | 519 | |
| 6461 |
Header
|
12년 전 | 720 | |
| 6460 |
희망과열정
|
12년 전 | 1343 | |
| 6459 |
프리랜서개발자
|
12년 전 | 1663 | |
| 6458 | 12년 전 | 1318 | ||
| 6457 |
jinmuk
|
12년 전 | 1930 | |
| 6456 |
jinmuk
|
12년 전 | 2335 | |
| 6455 |
jinmuk
|
12년 전 | 3190 | |
| 6454 |
jinmuk
|
12년 전 | 2157 | |
| 6453 |
jinmuk
|
12년 전 | 2333 | |
| 6452 |
jinmuk
|
12년 전 | 2300 | |
| 6451 |
jinmuk
|
12년 전 | 1583 | |
| 6450 |
jinmuk
|
12년 전 | 1388 | |
| 6449 |
jinmuk
|
12년 전 | 1034 | |
| 6448 |
jinmuk
|
12년 전 | 1223 | |
| 6447 |
jinmuk
|
12년 전 | 2002 | |
| 6446 |
jinmuk
|
12년 전 | 1560 | |
| 6445 |
jinmuk
|
12년 전 | 1260 | |
| 6444 |
jinmuk
|
12년 전 | 2300 | |
| 6443 |
jinmuk
|
12년 전 | 2036 | |
| 6442 |
jinmuk
|
12년 전 | 1877 | |
| 6441 |
jinmuk
|
12년 전 | 1612 | |
| 6440 |
jinmuk
|
12년 전 | 2313 | |
| 6439 |
jinmuk
|
12년 전 | 1129 | |
| 6438 |
wndProc
|
12년 전 | 771 | |
| 6437 | 12년 전 | 389 | ||
| 6436 |
senseme
|
12년 전 | 532 | |
| 6435 | 12년 전 | 1041 | ||
| 6434 | 12년 전 | 2471 | ||
| 6433 | 12년 전 | 2477 | ||
| 6432 | 12년 전 | 1556 | ||
| 6431 |
밥먹고합시다
|
12년 전 | 1180 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기