Re: Checking the season
| From: | Bogdan Stancescu | Date: | Sat, 05 Jan 2002 16:38:11 +0000 |
| Subject: | Re: Checking the season | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-79567@lists.php.net to get a copy of this message | ||
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