Wednesday, September 3, 2008

Project Calendar - First day of the month...

For quite a while, I have been doing some research on simple algorithms to find out what was the first day of the month, defining the offset. But then it hit me: "What if I just generate my date variable at the first of the current month?"...

Yes, that's all I had to do. Use mkdate(); using the current month and year (or user selected month and year) and make my date variable with the first day of the month. I can check the day of the week of any date variable with PHP...

...Simple!

I now have a working calendar that, by default, shows the current month. Users can then select a month and year (within certain ranges) and the calendar will change, with the correct number of days and the right starting day.

I'm cleaning up the code a little bit. I will upload it later and post the renderCalendar() function.