How To Issue Date Queries With MySQL
|Computing : Learning PHP|
Many people who know PHP at some stage need to work with a database.
And a typical interaction will be setting membership timeouts for a user database.
However most will not know about the powerful time and date functions you get with mySQL and will therefore spend time manipulating the date or time with PHP and then issuing a query.
However there are mySQL functions out there that will take the strain for you, for instance either adding to the date, subtracting from the date or even working out the difference between two dates.
To add to the date, for instance, you can simply use the adddate() function: notice the three d's, if you get confused use the synonymous date_add() function.
You pass to this function the interval as relevant, for instance 1 MONTH, and thus you save having to do any calculations with PHP first.
Questions about PHP and mySQL: