Does anyone know how to search on a datetime field using the filters? I’m displaying the date as follows:
$criteria->compare(‘insertTime’, $this->insertTime);
Thanks
Does anyone know how to search on a datetime field using the filters? I’m displaying the date as follows:
$criteria->compare(‘insertTime’, $this->insertTime);
Thanks
$criteria->compare("DATE_FORMAT(date, '%m/%d/%Y')",$this->date,true);
but this will depend on how you search the datetime (i.e. how it is displayed). In my case, I displayed the date as mm/dd/yyyy.
// $_GET['range1'] is an input and is used in an ajax search request.
if(isset($_GET['range1']) && ($_GET['range1'] !== NULL)) {
$startDate = date("Y-m-d 00:00:00", strtotime($_GET['range1']));
$criteria->compare('t.datetime_field', ' >= ' .$startDate);
}