Hi all.. It would seem that MySQL 4 stores dates as yyyy-mm-dd.. Can someone suggest their preferences for comparing a date retrieved from MySQL with the local server date.
Thanks
David
Comparing Dates
Moderator: General Moderators
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
You can convert the date to a unix timestamp and compare that against time(). Or you can select MONTH(date_field), DAY(date_field) and YEAR(date_field) from MySQL and compare each of those to date("M"), date("D") and date("Y).
There are probably other, better ways to do it as well. Off the top of my head I would be inclined to select the date as it is in MySQL and compare that to date("Y-M-D") in PHP.
There are probably other, better ways to do it as well. Off the top of my head I would be inclined to select the date as it is in MySQL and compare that to date("Y-M-D") in PHP.