current_date doctrine

0

Tchê,

I'm just trying to get information from the bank only when I have the same day as today, so I tried these 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'); 

But none of them brought me the result .... the field I want to bring is a timestamp, but I do not just need the date of this face.

Can anyone help me?

    
asked by anonymous 03.06.2015 / 15:35

2 answers

0

I did it this way:

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

Because of my field that is timestamp, I have to move on to saying that I just want the date in the case of date ().

    
03.06.2015 / 17:55
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 a time zone and the bank in another:

->where('a.data_hora = ?', new \DateTime('now', new \DateTimeZone('UTC')));
    
03.06.2015 / 17:26