TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
 
 
LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
Old 10-05-2009, 11:25 AM   #1 (permalink)
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 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:
<?php

class 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?
__________________
Tanax is offline  
Reply With Quote
 



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Adding Event to PHP Calendar buildakicker General 21 01-29-2013 12:01 PM
Coloring today and week-end in a calendar... Peuplarchie Advanced PHP Programming 5 12-05-2008 02:22 PM
Calendar Script - Week View oMIKEo Absolute Beginners 2 09-05-2008 09:11 PM
Calendar script needs template system nonenone General 3 04-16-2005 04:15 AM


All times are GMT. The time now is 02:46 AM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design