Forum Moderators: coopster
I was thinking about practicing my php skills by building a little script that draws a calendar on a page for the current month...maybe hilighting the current date also...(might add features other features if things go well and I have a use for it... )
I'm wondering, what are the basics behind those calendar scripts that already exist? What's the best method to use.. like, do you just make php get the current date and day of the week, and then fill the rest of the month relatively to that? Or is there some special algorithm we can use so that the computer knows the first day of month X of year Y is let's say a monday...
The first day of the month: what day of the week is it? That's where your "1" goes. You'll loop from 1 to the last day of the month, adding your calendar day array.
How many days last month? 31? Loop descending from 31 to fill in the front of the calendar.
What day of the week is the final day? You'll need to add values at the end for next month.
Then foreach($array as $key=>$value) and do your count 1-7, 1s will be beginning of the week rows. 7s are ends of rows.