Skip to content
Advertisement

Compare dates between datetimes with Doctrine

I have a Symfony2 application with a table that contains a date field, whose type is DateTime.
I need to get all the entities where that field value is now.

If I uses the following code, I get 0 results because Doctrine is comparing the DateTime object.

JavaScript

I need to only compare year, month, and day, not hours.

How can I achieve this?

Advertisement

Answer

I see this simple way:

JavaScript

then in your repository

JavaScript
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement