View Single Post
Old 12-02-2008, 07:50 PM   #5 (permalink)
Wildhoney
La Vida es Sueño
Advanced Programmer Top Contributor 
 
Wildhoney's Avatar
 
Join Date: Sep 2007
Location: Oldham
Posts: 2,258
Thanks: 90
Wildhoney is on a distinguished road
Default

I created a calendar class for TalkPHP. Although I never released it. I should do as it's very in-depth! The function I used for detecting if it is the weekend or not, is the following:

php Code:
public function isWeekend()
{
    list($iDay, $iMonth, $iYear) = explode(' ', date('d m Y', $this->m_iDate));
    $szDay = date('D', mktime(0, 0, 0, $iMonth, $iDay, $iYear));
   
    if($szDay == 'Sat' || $szDay == 'Sun')
    {
        return true;
    }
   
    return false;
}

The member variable $this->m_iDate is nothing more than a UNIX timestamp. This can obviously be created using time()! Perhaps somebody knows of a better way, however. In which case, I would love to hear it, as I love dealing with dates.
__________________
The man who comes back through the Door in the Wall will never be quite the same as the man who went out.
Send a message via AIM to Wildhoney Send a message via MSN to Wildhoney Send a message via Yahoo to Wildhoney
Wildhoney is offline  
Reply With Quote