whereTimestamp()
The whereTimestamp()
method is a strict wrapper for whereInt()
intended for columns that store UNIX timestamps (e.g., created_at
, last_seen
).
It enforces integer validation and ensures that values are safe, numeric, and suitable for time-based filtering.
Signature:
public function whereTimestamp(string $column, int $timestamp, string $operator = '='): self
public function orWhereTimestamp(string $column, int $timestamp, string $operator = '='): self
Basic Usage
Filter records where a timestamp column matches or exceeds a specific value:
$db->whereTimestamp('created_at', 1700000000);
$users = $db->get('users');
Allowed Input
The value must be a valid UNIX timestamp (i.e., a non-negative integer). The method will reject any string, float, or invalid format.
1700000000
→ ✅ accepted'1700000000'
→ ❌ rejected (string)now()
→ ❌ rejected (usetime()
or$db->now('U')
)'2024-01-01'
→ ❌ not a timestamp
Security Note
This method uses whereInt()
internally, so it inherits full type validation. Suspicious values or malformed timestamps are rejected.
All values are passed as bound parameters via prepared statements.
OR Version
orWhereTimestamp()
behaves identically but uses OR
logic instead of AND
.