I have the following function but have a problem in that my timestamp field in the database is a mysql timestamp type which is in format '2012-08-30 11:31:41' and the strtotime('-12 hours'); is giving a unix timestamp.
whats the solution?
public function checkIfItemVisited($user_id, $item_id) {
$timeago = strtotime('-12 hours');
$params = array(
':user_id' => $user_id,
':item_id' => $item_id,
':timestamp' => $timeago
);
$sql = "SELECT `visit_id` FROM `item_visits` WHERE `user_id` = :user_id AND `item_id` = :item_id AND `timestamp` > :timestamp";
$stmt = $this->query($sql, $params);
if($stmt->rowCount() > 0) :
return false;
else :
$this->countVisit($user_id, $item_id);
endif;
}