php - Comparing dates with Query Builder -


i trying add parameter addwhere in query builder make retrieve date similar today's date (matching month , day). dates stored in database looks 1895-04-14 00:00:00, if today 14-04 regardless year give me record. here's i've got far.

->select('r') ->where('r.status = :status') ->setparameter(':status', 1) ->andwhere('r.dateofdeath = :now') ->setparameter('now',\date("m-d", time())) ->getquery();  return $qb->getarrayresult(); 

how can entries database matching today's day , month?

since querybuilder should accept native sql-code:

->andwhere('r.dateofdeath >= now()') 

should work...

or

->setparameter('now', (new \datetime()->format('y-m-d h:i:s'))) 

if using php 5.4 or higher should work


Comments

Popular posts from this blog

css - SVG using textPath a symbol not rendering in Firefox -

Java 8 + Maven Javadoc plugin: Error fetching URL -

order - Notification for user in user account opencart -