Re: Checking the season

From: Date: Sun, 06 Jan 2002 01:34:25 +0000
Subject: Re: Checking the season
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-79590@lists.php.net to get a copy of this message
I'll have to use and if/elseif construct, because I don't believe a switch() constructs cases can take expressions, can it? ----- Original Message ----- From: "Bogdan Stancescu" <mgv@fx.ro> To: "webapprentice" <webapprentice@onemain.com> Cc: <php-general@lists.php.net> Sent: Saturday, January 05, 2002 11:38 AM Subject: Re: [PHP] Checking the season > You could do a case() or if/elseif, check if it's spring, summer or autumn and leave the code for winter as default/else. > > Bogdan > > webapprentice wrote: > > > Hi, > > Just need a sounding board to help me think this through. > > > > I want to check the current date to determine what "season" it is and display the appropriate picture. > > > > I define spring as 03/21/YYYY, summer as 06/21/YYYY, autumn as 09/21/YYYY, and winter as 12/21/YYYY. > > > > I form a string for the current date and get a timestamp via mktime(). > > I also get the equivalent timestamps for the dates above for the seasonal changes. > > > > Then, I compare the current date to see if it's between the seasonal dates. > > The problem is when I go from 12/31/YYYY to 01/01/(YYYY+1). > > Since winter and spring dates are one year apart, the current date timestamp comparison gets messed up and nothing displays. > > > > How do I do a proper comparison? I was thinking of just seeing if the current date timestamp is greater than each of the seasonal date timestamp, but it feels like I would miss something. Would I? Or is there another solution? > > > > Thank you for your time. > > > > --Stephen > >

« previous php.general (#79590) next »