determine date range

From: Date: Wed, 12 Dec 2007 16:39:53 +0000
Subject: determine date range
Groups: php.general 
Request: Send a blank email to php-general+get-265774@lists.php.net to get a copy of this message
I'm working on hotel type booking script where prices will vary depending on the season. prices are updated every year so i need to take a user inputed date and determine which season the date falls under. i figured i can convert all dates into a timestamp and then run a series conditional statements to see which returns true. something like this: // date ranges $dates[1]['start'] = mktime(0, 0, 0, '01', '04', date('Y')); $dates[1]['end'] = mktime(0, 0, 0, '04', '14', date('Y')); $dates[2]['start'] = mktime(0, 0, 0, '04', '15', date('Y')); $dates[2]['end'] = mktime(0, 0, 0, '08', '18', date('Y')); $dates[3]['start'] = mktime(0, 0, 0, '08', '19', date('Y')); $dates[3]['end'] = mktime(0, 0, 0, '12', '23', date('Y')); $dates[4]['start'] = mktime(0, 0, 0, '12', '14', date('Y')); $dates[4]['end'] = mktime(0, 0, 0, '01', '03', date('Y') + 1); // tstamp is user inputed date if($tstamp >= $dates[1]['start'] && $tstamp <= $dates[1]['end']){ return 1; } if($tstamp >= $dates[2]['start'] && $tstamp <= $dates[2]['end']){ return 2; } if($tstamp >= $dates[3]['start'] && $tstamp <= $dates[3]['end']){ return 3; } if($tstamp >= $dates[4]['start'] && $tstamp <= $dates[4]['end']){ return 4; } now, not sure why this isn't working...but it's not returning true for any of these. also i'm realizing i need to account for people who decide to book a date a year ahead, in which case this approach will break since all timestamp date ranges (except for $date[4]['end']) are set to the current year. any suggestions on how i should approach this problem?

« previous php.general (#265774) next »