![]() |
Add date format to Language - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28) +--- Forum: CodeIgniter 4 Feature Requests (https://forum.codeigniter.com/forumdisplay.php?fid=29) +--- Thread: Add date format to Language (/showthread.php?tid=80693) |
Add date format to Language - Danilo - 12-03-2021 CodeIgniter 4.1.5 If I set: PHP Code: app\Config\App.php With this code: PHP Code: use CodeIgniter\I18n\Time; OUTPUT: Quote:lug 31, 2021 This is terrifying to see. The month has been translated into Italian, but the format is in English (month day year). But in Italian the date is written: day month year. This is my suggestion. system\Language\en\Time.php ADD PHP Code: //Format strings by date and time system\Language\it\Time.php ADD PHP Code: //Format strings by date and time system\I18n\Time.php override this methods: PHP Code: public function toDateTimeString(?bool $toLocale = true) AND REPLACE: ->toDateTimeString() TO: ->toDateTimeString(false) (4 replacements) NOW PHP Code: echo "<br>" . $miaData->toFormattedDateString(); $defaultLocale = 'it'; Quote:31 lug 2021 $defaultLocale = 'en'; Quote:Jul 31, 2021 EDIT: The user can easily overwrite the format, modifying the file MYAPP/app/Language/it/Time.php |