Check installed timezones on server and use them

Published March 4, 2020 • 1 min read

Use the following commands on your operating system (Linux, MacOS) to see which languages are installed

locale -a

Then you get for example the following displayed:

C
C.UTF-8
de_DE.utf8
en_AG
en_AG.utf8
en_AU.utf8
en_BW.utf8
en_CA.utf8
en_DK.utf8
en_GB.utf8
en_HK.utf8
en_IE.utf8
en_IN
en_IN.utf8
en_NG
en_NG.utf8
en_NZ.utf8
en_PH.utf8
en_SG.utf8
en_US.utf8
en_ZA.utf8
en_ZM
en_ZM.utf8
en_ZW.utf8
POSIX

For example, if you want to have a German date displayed, you now know that you can use de_DE.utf8.

So in PHP it could look like this:

<?php

setlocale(LC_ALL, "de_DE.utf8");

strftime("%A, %d. %B %Y", strtotime('2020-03-03'));

Output:

Dienstag, 04. März 2020


php server

Join my mailing list