이번달 달력(양력)을 표시하는 소스입니다. 조금만 응용하면 여러가지 모양이 나올 수 있겠죠!
<?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 님과 동감이라는.. ㅡ,.ㅡ
게시판 목록
프로그램
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 6430 | 12년 전 | 963 | ||
| 6429 | 12년 전 | 9095 | ||
| 6428 | 12년 전 | 591 | ||
| 6427 |
제이티37
|
12년 전 | 1564 | |
| 6426 |
프로프리랜서
|
12년 전 | 1144 | |
| 6425 |
프로프리랜서
|
12년 전 | 1603 | |
| 6424 |
프로프리랜서
|
12년 전 | 1803 | |
| 6423 | 12년 전 | 997 | ||
| 6422 |
퍼블리셔지노군
|
12년 전 | 1567 | |
| 6421 | 12년 전 | 2204 | ||
| 6420 |
|
12년 전 | 1333 | |
| 6419 |
|
12년 전 | 1283 | |
| 6418 | 12년 전 | 1180 | ||
| 6417 |
senseme
|
12년 전 | 7416 | |
| 6416 |
senseme
|
12년 전 | 1320 | |
| 6415 |
senseme
|
12년 전 | 1184 | |
| 6414 |
senseme
|
12년 전 | 1959 | |
| 6413 |
senseme
|
12년 전 | 958 | |
| 6412 |
senseme
|
12년 전 | 1481 | |
| 6411 |
senseme
|
12년 전 | 1087 | |
| 6410 |
senseme
|
12년 전 | 1038 | |
| 6409 |
PASKRAN
|
12년 전 | 2812 | |
| 6408 | 12년 전 | 10795 | ||
| 6407 | 12년 전 | 2987 | ||
| 6406 |
프로프리랜서
|
12년 전 | 2824 | |
| 6405 |
프로프리랜서
|
12년 전 | 1364 | |
| 6404 |
프로프리랜서
|
12년 전 | 2720 | |
| 6403 |
프로프리랜서
|
12년 전 | 815 | |
| 6402 |
프로프리랜서
|
12년 전 | 1720 | |
| 6401 |
프로프리랜서
|
12년 전 | 1138 | |
| 6400 |
프로프리랜서
|
12년 전 | 1457 | |
| 6399 |
프로프리랜서
|
12년 전 | 1179 | |
| 6398 |
프로프리랜서
|
12년 전 | 1478 | |
| 6397 |
프로프리랜서
|
12년 전 | 3596 | |
| 6396 | 12년 전 | 1865 | ||
| 6395 | 12년 전 | 914 | ||
| 6394 |
|
12년 전 | 5236 | |
| 6393 |
제이티37
|
12년 전 | 1195 | |
| 6392 |
songsinica
|
12년 전 | 1190 | |
| 6391 |
|
12년 전 | 3364 | |
| 6390 |
|
12년 전 | 1617 | |
| 6389 | 12년 전 | 4853 | ||
| 6388 |
스누피사랑
|
12년 전 | 5429 | |
| 6387 | 12년 전 | 1837 | ||
| 6386 | 12년 전 | 3049 | ||
| 6385 |
희망과열정
|
12년 전 | 922 | |
| 6384 | 12년 전 | 3284 | ||
| 6383 | 12년 전 | 10590 | ||
| 6382 |
|
12년 전 | 5783 | |
| 6381 |
SugarSkull
|
12년 전 | 1021 | |
| 6380 | 12년 전 | 771 | ||
| 6379 |
|
12년 전 | 1974 | |
| 6378 | 12년 전 | 1553 | ||
| 6377 | 12년 전 | 490 | ||
| 6376 |
후라보노보노
|
12년 전 | 1329 | |
| 6375 | 12년 전 | 2860 | ||
| 6374 | 12년 전 | 825 | ||
| 6373 | 12년 전 | 2366 | ||
| 6372 |
takumi22
|
12년 전 | 1237 | |
| 6371 |
개초보제이
|
12년 전 | 770 | |
| 6370 |
고급자가되고
|
12년 전 | 1454 | |
| 6369 | 12년 전 | 875 | ||
| 6368 | 12년 전 | 3175 | ||
| 6367 | 12년 전 | 1870 | ||
| 6366 | 12년 전 | 2872 | ||
| 6365 |
lilyosia
|
12년 전 | 1788 | |
| 6364 | 12년 전 | 1051 | ||
| 6363 | 12년 전 | 1582 | ||
| 6362 | 12년 전 | 2728 | ||
| 6361 | 12년 전 | 2552 | ||
| 6360 | 12년 전 | 998 | ||
| 6359 | 12년 전 | 2100 | ||
| 6358 |
|
12년 전 | 1784 | |
| 6357 |
에헤라디야자진방아를돌려라
|
12년 전 | 775 | |
| 6356 | 12년 전 | 2072 | ||
| 6355 | 12년 전 | 3780 | ||
| 6354 | 12년 전 | 3087 | ||
| 6353 | 12년 전 | 1542 | ||
| 6352 | 12년 전 | 7768 | ||
| 6351 | 12년 전 | 2531 | ||
| 6350 | 12년 전 | 2792 | ||
| 6349 | 12년 전 | 1870 | ||
| 6348 | 12년 전 | 3541 | ||
| 6347 | 12년 전 | 1443 | ||
| 6346 | 12년 전 | 1179 | ||
| 6345 | 12년 전 | 1832 | ||
| 6344 | 12년 전 | 1404 | ||
| 6343 |
프로프리랜서
|
12년 전 | 2058 | |
| 6342 |
프로프리랜서
|
12년 전 | 1373 | |
| 6341 |
프로프리랜서
|
12년 전 | 1810 | |
| 6340 |
프로프리랜서
|
12년 전 | 1890 | |
| 6339 |
프로프리랜서
|
12년 전 | 1328 | |
| 6338 |
프로프리랜서
|
12년 전 | 1565 | |
| 6337 | 12년 전 | 5252 | ||
| 6336 |
프로프리랜서
|
12년 전 | 1624 | |
| 6335 |
프로프리랜서
|
12년 전 | 947 | |
| 6334 |
프로프리랜서
|
12년 전 | 1321 | |
| 6333 |
프로프리랜서
|
12년 전 | 2437 | |
| 6332 | 12년 전 | 1095 | ||
| 6331 |
돗단배123
|
12년 전 | 1416 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기