I'd like to return records in a MySQL database based on whether the record date falls in between a time range (using PDO).
Time Range:
$rangeStart = "17-Jul-18 04:45 pm";
$rangeEnd = "17-Jul-18 05:30 pm";
Method:
public function getForTokenIDAddressAndDateRange($token_id, $address, $rangeStart, $rangeEnd) {
$sql = "SELECT * FROM `{$this->table}` WHERE `token_id` = ? AND `address` = ? AND `date` <= ? AND `date` >= ?";
$stmt = $this->pdo->prepare($sql);
$stmt->execute([$token_id, $address, strtotime($rangeStart), strtotime($rangeEnd)]);
}
Example "date" value from a record:
17-Jul-18 5:04 pm
How can I make the above method work properly? I believe I need to convert the "date" column value to a timestamp, but not sure how. thx!