current_date Doctrine

Asked

Viewed 142 times

0

Bye,

i’m wanting to bring the bank information only when it has the same day as today I tried those ways:

 ...
 ->where('a.data_hora = ?', current_date());
 ....
 ->where('a.data_hora = current_date');
 .....
 $data = date("Y-m-d");
 ->where('a.data_hora = ? ', $data);
 .. 
 ->where('a.data = data'); 

only that none brought me the result .... the field I want to bring is a timestamp, but I don’t need just this guy’s date.

Can someone help me?

2 answers

0

Use the class \DateTime to generate a current date:

->where('a.data_hora = ?', new \DateTime('now')); // ou simplesmente new \DateTime()

You can still specify the time zone if the application is in one time zone and the bank in another:

->where('a.data_hora = ?', new \DateTime('now', new \DateTimeZone('UTC')));
  • but with datetime he will not seek information about date and time ?

0


I got it this way:

 ->where(' date(a.data_hora) = current_date ');

because of my field which is timestamp, I have to go to saying that I just want the date, in case of the date().

Browser other questions tagged

You are not signed in. Login or sign up in order to post.