Welcome to WebmasterWorld Guest from 54.160.163.163

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

racking my brain - php dates

     

Crump

10:44 pm on Jan 25, 2011 (gmt 0)

10+ Year Member



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

10:50 pm on Jan 25, 2011 (gmt 0)

WebmasterWorld Administrator lifeinasia is a WebmasterWorld Top Contributor of All Time 5+ Year Member Top Contributors Of The Month



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

10:58 pm on Jan 25, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



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

brotherhood of LAN

1:15 am on Jan 26, 2011 (gmt 0)

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



>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...]
 

Featured Threads

Hot Threads This Week

Hot Threads This Month