Level 73
I really suggest you store both values in the same column, because this design is bad. How ever you should be able to do
date(now()), time(now())
1 like
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
We have a times table with below structure:
create table times
(
id bigint unsigned primary key,
user_id bigint unsigned not null,
day date not null,
time time not null
)
collate = utf8mb4_unicode_ci;
create index on times (day);
create index times_time_index on times (time);
day sample is '2022-09-18' and time sample is '13:10:00'
What is best query for selecting times > now()?
If you want to get records where the date date/time is in the future;
Date needs to be today AND time needs to be later
OR
Date needs to be after today and time can be anything
->where(function($query){
$query->where('day', today())->where('time', '>', now()->format('H:i:s')
})
->orWhere('day', '>', today())
->get()
Please or to participate in this conversation.