RE: [PHP] date comparison

From: Date: Mon, 11 Nov 2002 06:19:00 +0000
Subject: RE: [PHP] date comparison
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-123779@lists.php.net to get a copy of this message
> I have a problem here again regarding the date comparison. I need to > check the most recent date that was entered in mysql database in date > format ("Y-m-d"), if the datetoday is a day or two days in advanced > compared to the queried date. > I need to make sure that the next inserted date in the mysql database > whould be the next day of the last inserted date. Wow...that's confusing. :) You will probably want to look at the DATE_SUB and DATE_ADD functions in MySQL. They are in the Date and Time section of Chapter 6 in the manual. Something like this would insert the "date" and the day after it into two columns in the database. $date = '2002-10-31'; $r = mysql_query("INSERT INTO your_table (todaydate, tomorrowdate) VALUES ('$date','$date' + INTERVAL 1 DAY)"); INTERVAL is a shortcut to the DATE_SUB and DATE_ADD functions. ---John Holmes...

« previous php.general (#123779) next »