I have a table with records of users (name, forename, birthdate, etc.) and I want to find users by name or birthdate or every possible combination of this.
My code works well, but the birthdate is stored in the american format (YYYY-MM-dd), so I have to search after dates in this format to get the right record. That´s really annoying, because in Germany we use the european format (dd.MM.YYYY) and I want to search for the dates by our habitual format. Now I need help to give the input field the european format and get the right record.
I hope, you understand my issue. :)
Here is an extract of my Controller-Code:
$name = $this->request->data['name'];
$forename = $this->request->data['forename'];
$birthdate = $this->request->data['birthdate'];
if($name || $forename || $birthdate){
$query = $this->find()
->where([
'name LIKE' => '%'.$name.'%',
'forename LIKE' => '%'.$forename.'%',
'birthdate LIKE' => '%'.$birthdate.'%'
]);
$number = $query->count();
$this->set('users', $this->paginate($query));
$this->set('_serialize', ['users']);
}
And here is the related part of the code from my view:
foreach($users as $user):
h($user->name)
h($user->forename)
h($user->birthdate)
endforeach;
Thank you very much.