If birthdate’s are stored as type “Date” in MySQL, how would you determine if it’s a specific user’s birthday today in PHP?
Is it simply a matter of grabbing the birthdate column value, doing on a explode on the -, and then checking if the day and month match the current day and month in PHP? Or is there a simpler and less crude way of doing it?
Also, what query would you use to SELECT all users whose birthday it is today?
Since you’ll need to exclude the year, you can use the
MONTHandDAYSQL functions like so:Don’t forget to add an index on this column or it will seriously degrade performance as data grows.
In PHP, you can just use the date function: