php basit bir takvim fonksiyonu

php basit bir takvim fonksiyonu



function showCalendar(){
// Get key day informations.
// We need the first and last day of the month and the actual day
$today = getdate();
$firstDay = getdate(mktime(0,0,0,$today['mon'],1,$today['year']));
$lastDay = getdate(mktime(0,0,0,$today['mon']+1,0,$today['year']));

// Create a table with the necessary header informations

// Display the first calendar row with correct positioning
echo '

';
if ($firstDay['wday'] == 0) $firstDay['wday'] = 7;
for($i=1;$i<$firstDay['wday'];$i++){<br/>
}
$actday = 0;
for($i=$firstDay['wday'];$i<=7;$i++){<br/> $actday++;
if ($actday == $today['mday']) {
$class = ' class="event"';
} else {
$class = '';
}
echo '
'.$actday.'
';
}

//Get how many complete weeks are in the actual month
$fullWeeks = floor(($lastDay['mday']-$actday)/7);

for ($i=0;$i<$fullWeeks;$i++){<br/> //echo '
';
for ($j=0;$j<7;$j++){<br/> $actday++;
if ($actday == $today['mday']) {
$class = ' class="event"';
} else {
$class = '';
}
echo '
'.$actday.'
';
}

}

//Now display the rest of the month
if ($actday < $lastDay['mday']){

for ($i=0; $i<7;$i++){<br/> $actday++;
if ($actday == $today['mday']) {
$class = ' class="event"';
} else {
$class = '';
}

if ($actday <= $lastDay['mday']){<br/> echo '
'.$actday.'
';
}
else {

}
}

}

}
Scroll to Top