Hi all,
I have stored two dates in my mysql table. Starting date and ending date for the survey. Now from php, how can i extract if current_date is greater then end_date. The dates are being stored in datetime format in mysql.
Kindly guide me
| SitePoint Sponsor |
Hi all,
I have stored two dates in my mysql table. Starting date and ending date for the survey. Now from php, how can i extract if current_date is greater then end_date. The dates are being stored in datetime format in mysql.
Kindly guide me


you should actually do this with mysql, not php
CURRENT_DATE is the standard sql function for the current dateCode:WHERE end_date < CURRENT_DATE
it's more efficient than passing in the current date from php, as in '2012-10-15', because mysql would first have to parse that to make sure it's actually a valid date


I agree; it would be better to do it in the DB. If you HAD to do it in PHP though, it's pretty easy.
PHP Code:if ($row['end_date'] < date('Y-m-d H:i:s')) {

<?php//Kyle Wolfeecho devBlog("My Dev Notes");
Bookmarks