PHP: why is my date configured on the server differently?

With the following source code, I get different outputs on dev (local-maxOSX) and live (debian):

setlocale(LC_TIME, 'de_DE' ); $intervalOutput = strftime('%a %d.%m. %H:%M', $start->getTimestamp()); echo $intervalOutput; 

local (correct formatting of the day): Do 01.03. 20:00

live server (wrong - I need a way out on a weekday): Thu 01.03. 20:00

Can someone tell me why this is happening?

0
source share
3 answers

try using date_default_timezone_set or try using LC_ALL

+1
source

I thought this worked for me (which is why I wrote this answer here), but later I realized that now this does not work on dev (OSX). (So ​​I just edited this answer) You can try anyway:

1.) installation of locales on a real server (with root privileges):

 aptitude install debconf dpkg-reconfigure locales 

2.) change:

 setlocale(LC_TIME, 'de_DE') 

to

 setlocale(LC_TIME, 'de_DE.UTF8') 

The reason this doesn't work for me seems to be that on OSX the locale is called "de_DE.utf-8", whereas on a debian machine it is called "de_DE.UTF8".

+1
source

Try the following on both machines.

 $loc_de = setlocale(LC_ALL, ' de_DE@euro ', 'de_DE', 'de', 'ge'); echo "Preferred locale for german on this system is '$loc_de'"; 
0
source

All Articles