Discuss Get upcomming birthdays in the PHP Development forum on Dev Shed. Get upcomming birthdays PHP Development forum discussing coding practices, tips on PHP, and other PHP-related topics. PHP is an open source scripting language that has taken the web development industry by storm.
Time spent in forums: 8 h 55 m 59 sec
Reputation Power: 0
Yes I know, I hate it too.. I also hate all this date conversion, gives me a big headache. The system works like this, I didn't make it, nor can I change it. I guess ill just go fetching all users and covert the birthdays one by one =_="
Time spent in forums: 3 Days 8 h 45 m 39 sec
Reputation Power: 5
It sounds your simply wishing to select a range...? The range can be done as one of follows:
SELECT *,(FROM_UNIXTIME(`dateOfBirth`)) as 'bday' FROM `member` WHERE `dateOfBirth` >= [start date] AND `dateOfBirth` <= [end date]
SELECT *,(FROM_UNIXTIME(`dateOfBirth`)) as 'bday' FROM `member` WHERE `dateOfBirth` BETWEEN [start date] AND [end date]
As far as defining your start/end date, simply find current date, and if Day of Week is NOT equal to 1, then start date is the following day equaling 1, otherwise current date. End date is just add 6 days to that, so that should be no prob.
EDIT: Actually, I should ask this first. When you say birthdays in the UPCOMING week, do you mean the current day plus the next 6 days? Or if today is Tuesday, do you want birthdays for the next Sunday thru Saturday?
EDIT2: I figure I'd toss some options in to maybe help you speed this up and not have to wait...
//if start day is current day
$start = time();
//if start day is set day of week
$start = strtotime("next Sunday");
//set 6 days later
$end = $start + 518400;