You can download a complete calendar script as well.
Step 1.
First of all try to collect the necessary information which are important to display the actual month and highlight the actual day. Besides this we want to display the actual month and year informations as well. To do this we need 3 special days informations:
- The actual day
- The first day of the actual month
- The last day of the actual month
With the above mentioned informations we can decide what day was the first day, how long is the month and of course which is the actual day.
Step 2.
To get the information mentioned in Step 1 we will use the PHP built in function: getdate(). Without parameters this function returns the actual day informations in an array as follows:
ArrayTo get the last day of the month with getdate we need to try to get the 0. day of the next month. So the code to get the information looks like this:
(
[seconds] => 40
[minutes] => 58
[hours] => 21
[mday] => 17
[wday] => 2
[mon] => 6
[year] => 2003
[yday] => 167
[weekday] => Tuesday
[month] => June
[0] => 1055901520
)
<?php
$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']));
?>
discuss this topic to forum
