Page 1 of 1
Comparing Dates
Posted: Tue Dec 27, 2005 7:19 pm
by dwessell
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
Posted: Tue Dec 27, 2005 8:49 pm
by RobertGonzalez
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.