I have a query I am trying to build with the laravel eloquent query builder. I'm relatively new to Laravel and I'm looking for the method that will query against a date AND a time.
My use case: Fetch the child records for MyModel created in the last hour.
My query:
$childQuery = function($query) {
$timezone = new Timezone('UTC');
// whereDate only compares a Date value
// whereTime only compares the Time value
$query->whereDate('custom_timestamp'
,'>='
, Carbon::now($timezone)->addSeconds(-3600));
};
MyModel::with(['myChildModels' => $childQuery])->find($myModelId);
How do I perform a timestamp comparison? I'm sure I am just missing something simple, but amazingly enough I couldn't find a single reference in the docs to comparing timestamps.