Im coding a text-based mafia game in norwegian and need help with time detection. So here’s the deal. In way to delete a mysql-record if time since a player bought the product is over midnight (24 hours clock). Here is what I tried, but in unsure it’s the best method:
// Har livvakt? (Has bodyguard)
if($this->isTheftProtected($user_id)){
$sql = mysql_query("SELECT * FROM `UserTing` WHERE t_meta = '2' AND t_owner = '".$user_id."'");
$rows = mysql_fetch_array($sql);
$timeThen = date("Hi", $rows["t_time"]);
$theNow = date("Hi");
if($timeThen > 0000){
// Slett produktet <- Delete here... past midnight.
} else {
// Behold.
}
} else {
return;
}
So, is there a better way. Should time() be considered to be used? Its really how to do this that my question is.
Regards. 😉
You might need to add cronjob or just run this query before
SELECTto delete old records.JOINS also can be used…