| Welcome to WebmasterWorld Guest from 184.108.40.206 |
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
|Subscribe and Support WebmasterWorld|
|racking my brain - php dates|
| 10:44 pm on Jan 25, 2011 (gmt 0)|
I've been trying to figure this one out, and I think my head is going to explode. I have 4 dates, that establish two parts to a year. Like this:
4/10 - 9/20 = Season 1
9/21 - 4/9 = Season 2
Then I have a date, and I need to figure out which Season it goes in.
For instance, 4/25 would go in season 1.
11/12 would go in season 2.
The years are not important.
I can't figure a way to approach this in PHP. My brain hurts! Please help!
| 10:50 pm on Jan 25, 2011 (gmt 0)|
Option 1: Convert everything to dates and use the usual date comparison functions.
Option 2: Convert all the dates to a 4-character string (MMDD) (making sure you put leading zeros in the day or month <10) and do a simple string comparison.
In both cases, just test if between April 10 and Sept. 20. If so, it's season 1. Otherwise, it must be season 2.
(I don't know PHP, so I can't give you the specific functions or code to accomplish it, but this will hopefully point you in the right direction.)
| 10:58 pm on Jan 25, 2011 (gmt 0)|
Convert to a timestamp. Easier to check the range I would think.
|brotherhood of LAN|
| 1:15 am on Jan 26, 2011 (gmt 0)|
and/or ranges.. this PHP function may be useful to you, it takes dates in string format and converts them to a 4 byte UNIX timestamp.
All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
© Webmaster World 1996-2013 all rights reserved