Format date before save or show |
Hi Pip
I'm from germany and I had the same problem. My site supports two languages with different format of the date to input. In my model (CI4) I made two changes: First: PHP Code: protected $beforeInsert = ['getFormatedDate']; And second (the callback code for the $beforeInsert/$beforeUpdate): PHP Code: protected function getFormatedDate(array $data) The third thing I made is to check the input data via validation IN THE LANGUAGE THE USER SET. For this I created own rules for each language: PHP Code: public function format_date(string $str = null): bool I have in my database for each language ONE DateTimeFormat : Y-m-d H:i:s I hope, I could help yout to solve your problem ;) Greetinxx Kighlander |
Messages In This Thread |
Format date before save or show - by pippuccio76 - 01-28-2021, 11:15 AM
RE: Format date before save or show - by InsiteFX - 01-28-2021, 12:21 PM
RE: Format date before save or show - by pippuccio76 - 01-28-2021, 12:56 PM
RE: Format date before save or show - by InsiteFX - 01-28-2021, 02:55 PM
RE: Format date before save or show - by demyr - 01-28-2021, 11:01 PM
RE: Format date before save or show - by Codinglander - 01-30-2021, 06:56 AM
|