mysql - Display things with time with php -
i want display gitfs specific timeslot, when try method, display old gifts . want display gifts dating there 1 week.
$midnight = strtotime("now -7 days"); $message = ''; $user = xxx_variable $stmt = $this->conn->prepare("select * gifts to_user = ? , time > ? order time desc limit 1, 25"); $stmt->bindvalue(1, $user, pdo::param_str); $stmt->bindvalue(2, $midnight, pdo::param_str);
try this..
you need use "unix_timestamp".
unix_timestamp(current_date - interval 7 day) -- 7 days ago
$stmt = $this->conn->prepare("select * gifts to_user = ? , time > ? order time desc limit 1, 25"); $stmt = $this->conn->prepare("select * gifts to_user = ? , time >= unix_timestamp(current_date - interval 7 day) order time desc limit 1, 25");
Comments
Post a Comment