Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

haizone's avatar

where() with datetime field

i try need to make a query with data time filed the date and the time in the field is important

i try to make something like that but isn't work: where('start_date_time' , '>=' , now())

i try with whereDate() too but isn't work and filter for me only the date

how i can do that? thanks

0 likes
3 replies
AungHtetPaing__'s avatar

@haizone Is your start_date_time value format same with now()? Check your start_date_time format and now() format.

kokoshneta's avatar

Please be more specific. What does “doesn’t work” mean? What actually happens? What database are you using?

Your query should be correct: ->where('start_date_time', '>=', now()) will select only rows whose start_date_time column is greater than or equal to the current time, assuming start_date_time is a DateTime column.

Please or to participate in this conversation.