homepage Welcome to WebmasterWorld Guest from 54.227.20.250
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
racking my brain - php dates
Crump

5+ Year Member



 
Msg#: 4258105 posted 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!

 

LifeinAsia

WebmasterWorld Administrator lifeinasia us a WebmasterWorld Top Contributor of All Time 5+ Year Member



 
Msg#: 4258105 posted 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.)

willybfriendly

WebmasterWorld Senior Member 10+ Year Member



 
Msg#: 4258105 posted 10:58 pm on Jan 25, 2011 (gmt 0)

Convert to a timestamp. Easier to check the range I would think.

brotherhood of LAN

WebmasterWorld Administrator brotherhood_of_lan us a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



 
Msg#: 4258105 posted 1:15 am on Jan 26, 2011 (gmt 0)

>timestamp

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.

[php.net...]

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved