Welcome Guest, Not a member yet? Register   Sign In
Format Date in a foreign language
#1

Hi,

i need the weekday in german and want to use the CI4 Time library.

PHP Code:
use CodeIgniter\I18n\Time;

$time Time::parse('2022-12-10');
echo 
$time->format('D. d.m.Y'); 

This gives me the english weekday. Is this a setting from CI or a PHP setting? In CI4 i added "de" to defaultLocale and supportedLocales but it is not working.
Reply
#2

PHP Code:
$time->toLocalizedString('D. d.m.Y'); 
Reply
#3

(12-10-2022, 03:58 PM)Mni.day Wrote:
PHP Code:
$time->toLocalizedString('D. d.m.Y'); 

This is not working, because the date format string is another one. but i will try it. Then i have to change alle date strings in my app.
Reply
#4

You can also use IntlDateFormatter::format
PHP.NET - IntlDateFormatter::format
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#5

(This post was last modified: 12-11-2022, 04:43 AM by groovebird.)

(12-11-2022, 01:54 AM)InsiteFX Wrote: You can also use IntlDateFormatter::format
PHP.NET - IntlDateFormatter::format

I think CI uses IntlDateFormatter under the hood if i use the "toLocalizedString" method.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB