If birthdate's are stored as type "Date" in MySQL, how would you determine if it's a user's birthday today in PHP? -


if birthdate's stored type "date" in mysql, how determine if it's specific user's birthday today in php?

is matter of grabbing birthdate column value, doing on explode on -, , checking if day , month match current day , month in php? or there simpler , less crude way of doing it?

also, query use select all users birthday today?

since you'll need exclude year, can use month , day sql functions so:

select * table month(birthday) = month(now()) , day(birthday) = day(now()); 

don't forget add index on column or degrade performance data grows.

in php, can use date function:

if (date('m-d', strtotime($row['date'])) == date('m-d'))     //-- today birthday! hooray! 

Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -