달력소스입니다.
본문
이번달 달력(양력)을 표시하는 소스입니다. 조금만 응용하면 여러가지 모양이 나올 수 있겠죠!
<?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><
<?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><
첨부파일
달력.txt (1.9 KB, 28회)댓글 4개
천재조상훈
12년 전
감사요
12년 전
감사
12년 전
감사
12년 전
감사합니다.
게시글 목록
| 번호 | 제목 |
|---|---|
| 26447 |
기획서
사이트맵
11
|
| 26436 |
기획서
사이트제작순서 (참고)
10
|
| 5279 | |
| 5276 | |
| 30674 | |
| 18417 |
JavaScript
계층형 카테고리를 여러개 선택할수 있게 하는방법이 없을까요??
|
| 18414 |
jQuery
슬라이드 업 전체메뉴에 대해 질문드립니다.
2
|
| 5261 | |
| 27054 | |
| 5259 | |
| 5239 | |
| 18413 | |
| 31486 |
반응형웹
7. 서버측 반응형 웹 접근방법
17
|
| 18410 | |
| 18400 |
MySQL
mysql like 검색방법
9
|
| 30670 |
웹접근성
웹접근성이란?
3
|
| 5231 | |
| 18395 |
JavaScript
자바스크립트를 이용해서 모바일에 selet 박스 구현한것입니다
4
|
| 18387 |
jQuery
jquery로 펼침 메뉴 입니다.
7
|
| 18381 | |
| 30661 |
웹접근성
웹표준형 화면 확대/축소
8
|
| 5222 | |
| 18380 | |
| 27043 | |
| 18366 |
Mobile
끊기지 않는 세션을 만들려면 어떻게?
13
|
| 24478 | |
| 18359 | |
| 30660 | |
| 18355 |
MySQL
csv 편집 방법?
3
|
| 18351 | |
| 18343 | |
| 18333 | |
| 31439 |
반응형웹
6. 반응형 이미지
46
|
| 18329 |
JavaScript
자바스크립트 해킹 공격에 대한 방어
3
|
| 18323 | |
| 27040 | |
| 30655 | |
| 5211 | |
| 31427 |
반응형웹
잠깐글2. 반응형 테이블
11
|
| 5205 | |
| 5193 | |
| 5184 | |
| 18317 |
jQuery
jQuery Quick Api Reference
5
|
| 27032 | |
| 18313 | |
| 30647 |
CSS
그라디언트 에디터
7
|
| 31408 | |
| 30644 | |
| 18306 | |
| 18303 | |
| 18288 | |
| 27028 | |
| 18285 | |
| 31383 |
반응형웹
5. 반응형 네비게이션/메뉴
24
|
| 27024 | |
| 5174 | |
| 18276 |
Mobile
디바이스별 viewport 설정. (수정본)
8
|
| 27017 | |
| 27130 | |
| 18274 | |
| 26427 | |
| 5170 | |
| 5160 | |
| 5157 | |
| 31371 | |
| 27010 | |
| 18267 | |
| 27003 | |
| 30636 | |
| 18265 | |
| 31350 |
반응형웹
4. 반응형 레이아웃
20
|
| 18262 | |
| 26998 | |
| 18260 |
jQuery
[펌] jQuery select box
1
|
| 26992 | |
| 26988 | |
| 18259 |
기타
구글 확장프로그램 추천
|
| 31328 |
반응형웹
3. 반응형 그리드
21
|
| 26986 | |
| 18257 |
정규표현식
캡쳐 그룹과 비캡쳐 그룹
1
|
| 26983 | |
| 5154 | |
| 26975 | |
| 24474 | |
| 31309 | |
| 26966 | |
| 31251 | |
| 18253 |
웹서버
php 업로드 용량 늘리기
3
|
| 31218 |
반응형웹
반응형 웹 강좌를 시작하며
32
|
| 31201 | |
| 26957 | |
| 26954 | |
| 5147 | |
| 5139 | |
| 18248 | |
| 5132 | |
| 26947 | |
| 31189 | |
| 30631 | |
| 26939 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기