10-05-2009, 11:25 AM
|
#1 (permalink)
|
|
The Prestige
Join Date: Sep 2007
Location: Sweden, Stockholm
Posts: 1,080
Thanks: 115
|
Calendar help
Hey!
I'm building a calendar class. It works quite well with getting the current month. Now I want to develop a system/function that makes it possible to change the month or year to future or history.
php Code:
<?phpclass Calendar { // The active date, day, month and year private $active_date; private $active_day; private $active_month; private $active_year; public function __construct() { // Do something? } public function month ($month = false, $year = false) { $this-> set($year, $month); return new Month ($this-> active_month, $this-> active_year); } private function set ($year = false, $month = false) { if($year == false && $month == false) { $this-> active_date = time(); $this-> active_day = date('d', $this-> active_date); $this-> active_month = date('m', $this-> active_date); $this-> active_year = date('Y', $this-> active_date); } }}
Month is a class that handles the month and calculates the days/weeks/blank days/etc. You don't have to care about that.
As you see I'm calling it via month() where I want to be able to set month and year. If only month is specified it should display the month that was set, with the current year(since that wasn't set). And if only year is set it should display the current month(since month wasn't set) but the year that was set.
If that makes any sense.
Any ideas how to solve that?
__________________
|
|
|
|