Localized date formats?

Hey, I’ve been trying to use localized date formats with PHP strftime() command.
But I can’t get it to work…
Any ideas on how to do that?
Or actually, is there another way to show dates in French?

Add the following to your config.php (of course the french equivalent):

setlocale(LC_ALL, 'de_DE');

After that you can use in your templates:

<?php echo strftime('%d. %B %Y', $page->date()); ?>

I think Kirby 2.1 will have better support for this …

Thanks @flokosiol.
It didn’t quite work for me.
Here’s what I’ve done in the end :

<?php setlocale(LC_ALL, 'fr_FR') ?>
<?php $uDate = $event->date('U','startDate') ?>
<?php echo strftime('%A %d %B', $uDate) ?>

It doesn’t look great but it works…

c::set('setlocale') is invalid. It should be c::set('locale', 'fr_FR');

In 2.1 you can switch the date handler with c::set('date.handler', 'strftime')

afterwards the date method works like this:

<?php echo $page->date('%A %d %B') ?>

and should respect your locale settings.


This looks a lot better!
Thanks @bastianallgeier

Thanks for the hint, @bastianallgeier. I played around again with these settings and could now figure it out for me, too.

On my local machine (OS X) I just need to set


On the server (CentOS) i need to set


Otherwise the german umlauts won’t be displayed correctly!
Thanks to the multi-environment setup this is easy to handle.

1 Like