Thread: Calendar help
View Single Post
Old 10-05-2009, 02:58 PM   #5 (permalink)
Tanax
The Prestige
Upcoming Programmer Inquisitive 
 
Tanax's Avatar
 
Join Date: Sep 2007
Location: Sweden, Stockholm
Posts: 1,080
Thanks: 115
Tanax is on a distinguished road
Default

Worked great!

php Code:
private function set($year, $month, $day)
    {
   
        $this->current_date = time();
        $this->current_day = date('d', $this->current_date);
        $this->current_month = date('m', $this->current_date);
        $this->current_year = date('Y', $this->current_date);
   
        // If no month nor year is specified, current month and year will be used
        if($year == false && $month == false)
        {
       
            $this->active_date = $this->current_date;
            $this->active_day = $this->current_day;
            $this->active_month = $this->current_month;
            $this->active_year = $this->current_year;
       
        }
       
        // If month is specified
        elseif($year == false && $month != false)
        {
       
            $this->active_date = mktime(0, 0, 0, $month, $day, $this->current_year);
            $this->active_day = date('d', $this->active_date);
            $this->active_month = date('m', $this->active_date);
            $this->active_year = date('Y', $this->active_date);
       
        }
       
        // If year is specified
        elseif($year != false && $month == false)
        {
       
            $this->active_date = mktime(0, 0, 0, $this->current_month, $day, $year);
            $this->active_day = date('d', $this->active_date);
            $this->active_month = date('m', $this->active_date);
            $this->active_year = date('Y', $this->active_date);
       
        }
       
        // If both year and month is specified
        else
        {
       
            $this->active_date = mktime(0, 0, 0, $month, $day, $year);
            $this->active_day = date('d', $this->active_date);
            $this->active_month = date('m', $this->active_date);
            $this->active_year = date('Y', $this->active_date);
       
        }
   
    }

How would you suggest I do the "navigation" of this calendar? So people can press like "next month", "next year", "last month", "last year", etc.

Should I do that with GET?
__________________
Tanax is offline  
Reply With Quote