d

달력 출력하기

· 2014-04-27 (일) 02:11:58 · 4820
<HTML>
<HEAD>
<TITLE>title</TITLE>
</HEAD>
<STYLE type='text/css'>
A:link {color:black;text-decoration:none;}
A:visited {color:black;text-decoration:none;}
A:hover {color:#0066cc;text-decoration:none;}
p,br,body,td {font-size:9pt;}
color:#0099cc; background-color:white}
</STYLE>

<BODY>
<TABLE width = '100%' height = '100%'>
<TR>
<TD align = 'center'>
<?php

if (!$year)
$year = date("Y");
    if (!$month)
    $month = date("m");

$day = 1;
$spacer = spacer( $year, $month, $day );
$endday = array( 31, 28, 31, 30 , 31, 30, 31, 31, 30 ,31 ,30, 31 );

    if( $year%4 == 0 && $year%100 != 0 || $year%400 == 0 )
        $endday[1] = 29;
        else
        $endday[1] = 28;


echo("
    <FONT color='#0066cc'>${year}년</FONT>
    <TABLE>
    <TR>
    <TD colspan = 7>
    ");
    for( $i = 1; $i <= 12; $i++ )
    {
        if( $i == $month )
        {
        echo("<A href = '$PHP_SELF?year=$year&month=$i'><FONT color='red'>${i}월 </FONT></A>");
        }
        else
        echo("<A href = '$PHP_SELF?year=$year&month=$i'>${i}월 </A>");
    }
echo("
    </TD>
    </TR>
    </TABLE>
    
    <TABLE>
    <TR>
    <TD align='center'>일</TD>
    <TD align='center'>월</TD>
    <TD align='center'>화</TD>
    <TD align='center'>수</TD>
    <TD align='center'>목</TD>
    <TD align='center'>금</TD>
    <TD align='center'>토</TD>
    </TR>
    <TR>
    ");

for( $i = 0; $i < $spacer; $i++ )
{
    echo("
        <TD> </TD>
        ");
    $tr++;
}


for( $i = 1; $i <= $endday[$month-1]; $i++ )
{
    if( $tr % 7 == 0 )
    {
        echo("
        </TR>
        <TR>
        <TD align = 'right'>$i</TD>
        ");
        $tr++;

    }
    else
    {
        echo("
            <TD align = 'right'>$i</TD>
            ");
        $tr++;
    }
}

$next_year = $year + 1;
$priv_year = $year - 1;
$next_year_ten = $next_year + 9;
$priv_year_ten = $priv_year - 9;


echo("
    </TR>
    </TABLE>

    <A href = '$PHP_SELF?year=$priv_year_ten&month=$month'> << </A>
        
    <A href = '$PHP_SELF?year=$priv_year&month=$month'> [-1] </A>
      
    <A href = '$PHP_SELF?year=$next_year&month=$month'> [+1] </A>
        
    <A href = '$PHP_SELF?year=$next_year_ten&month=$month'> >> </A>

    ");

        
function spacer( $year, $month, $day )
{
    $spacer = array(0, 3, 2, 5, 0, 3, 5, 1, 4, 6, 2, 4);
    $year = $year - ($month < 3);
    $result = ($year + (int) ($year/4) - (int) ($year/100) + (int) ($year/400) + $spacer[$month-1] + $day) % 7;
    return $result;
}
?>
</TD>
</TR>
</BODY>
</HTML>
|
댓글을 작성하시려면 로그인이 필요합니다.

프로그램

8,188건
+
제목 글쓴이 날짜 조회
16-03-02 조회 3,239
16-01-19 조회 2,526
15-12-23 조회 2,959
15-12-08 조회 3,674
14-10-30 조회 5,731
14-06-06 조회 5,554
12-08-30 조회 3,909
12-08-20 조회 3,828
12-07-15 조회 5,158
12-07-13 조회 3,629
12-07-06 조회 3,857
12-06-27 조회 3,366
12-06-23 조회 3,569
12-05-03 조회 5,181
12-04-20 조회 4,124
12-03-29 조회 4,632
12-03-22 조회 4,725
12-03-22 조회 3,509
12-03-21 조회 3,281
12-03-11 조회 3,713
12-03-06 조회 4,263
12-02-22 조회 4,532
12-02-17 조회 3,328
12-02-17 조회 6,179
12-02-14 조회 6,135
12-02-06 조회 4,260
12-01-18 조회 3,213
12-01-06 조회 3,442
11-12-30 조회 3,912
11-12-30 조회 7,057
11-12-21 조회 3,280
11-12-21 조회 4,243
11-12-16 조회 3,271
11-12-15 조회 3,322
11-12-15 조회 3,421
11-12-15 조회 4,222
11-12-09 조회 3,226
11-12-09 조회 3,308
11-12-07 조회 2,874
11-12-07 조회 3,960
11-12-05 조회 4,415
11-12-02 조회 3,861
11-12-01 조회 2,729
11-12-01 조회 2,775
11-12-01 조회 2,761