1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162
|
<?php
//This gets today's date
$date =time ();
//This puts the day, month, and year in seperate variables
$day = date('d', $date);
$month = date('m', $date);
$year = date('Y', $date);
//Here we generate the first day of the month
$first_day = mktime(0,0,0,$month, 1, $year);
//This gets us the month name
$title = date('n', $first_day);
if ($title == 1)
{
$title = 'Janvier';
}
elseif ($title == 2)
{
$title = 'Février';
}
elseif ($title == 3)
{
$title = 'Mars';
}
elseif ($title == 4)
{
$title = 'Avril';
}
elseif ($title == 5)
{
$title = 'Mai';
}
elseif ($title == 6)
{
$title = 'Juin';
}
elseif ($title == 7)
{
$title = 'Juillet';
}
elseif ($title == 8)
{
$title = 'Aout';
}
elseif ($title == 9)
{
$title = 'Septembre';
}
elseif ($title == 10)
{
$title = 'octobre';
}
elseif ($title == 11)
{
$title = 'Novembre';
}
else
{
$title = 'Décembre';
}
//Here we find out what day of the week the first day of the month falls on
$day_of_week = date('D', $first_day);
//Once we know what day of the week it falls on, we know how many blank days occure before it. If the first day of the week is a Sunday then it would be zero
switch($day_of_week)
{
case "Sun": $blank = 0; break;
case "Mon": $blank = 1; break;
case "Tue": $blank = 2; break;
case "Wed": $blank = 3; break;
case "Thu": $blank = 4; break;
case "Fri": $blank = 5; break;
case "Sat": $blank = 6; break;
}
//We then determine how many days are in the current month
$days_in_month = cal_days_in_month(0, $month, $year);
//Here we start building the table heads
echo "<table border=0 width=350 height=300>";
echo "<tr><th colspan=7> $title $year </th></tr>";
echo "<tr><td width=50 align=center>Di</td><td width=50 align=center>Lu</td><td width=50 align=center>Ma</td><td width=50 align=center>Me</td><td width=50 align=center>Je</td><td width=50 align=center>Ve</td><td width=50 align=center>Sa</td></tr>";
//This counts the days in the week, up to 7
$day_count = 1;
echo "<tr>";
//first we take care of those blank days
while ( $blank > 0 )
{
echo "<td></td>";
$blank = $blank-1;
$day_count++;
}
//sets the first day of the month to 1
$day_num = 1;
//count up the days, untill we've done all of them in the month
while ( $day_num <= $days_in_month )
{
echo "<td align=\"center\"> $day_num </td>";
$day_num++;
$day_count++;
//Make sure we start a new row every week
if ($day_count > 7)
{
echo "</tr><tr>";
$day_count = 1;
}
}
//Finaly we finish out the table with some blank details if needed
while ( $day_count >1 && $day_count <=7 )
{
echo "<td> </td>";
$day_count++;
}
echo "</tr></table>";
?> |
Partager