PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Not really, just store the timestamp of the expiration date in the database and then compare it with the currnt timestamp.
Use strtotime() to get the timestamp of a string like: '19 April 2006' and store it in your database.
When you want to compare between the current time to the expiration time simply pull the timestamp from the database and then compare it with what you get from time() - return the current timestamp.
well the big problem is when the expire date is over and the query wasnet made then the auction will not be over...
what i mean is that when ($date_now == $expire_date) the expire date has come... and the query isn't made - nobody entered the page to make the query so $expire_date has past and the changes were never executed...
/*
the code here until the next comment is executed when an auction is made
for example if someone is selling his shoes the auction expire days is two days since
the date the auction was made
*/
$today = date("Y-m-d");
$expire_days = time() + (2 * 24 * 60 * 60); // plus two days
$expire_date = date("Y-m-d", $expire_days); // this is sent to the DB
// when the expire date has come >>>
// expire date is pulled from the DB >>>
if($today == $expire_date) {
echo "auction is over!";
// some other things...
}