0

I have read other StachOverflow answers and forums about php and date but they did not help me. I am using bitnami in a Azure server and use date in the shell I get

Wed May 4 10:25:16 UTC 2016

. But with php date("d-m-y/H:i:s") function y get

04-05-16/03:18:51

I have changed the timezone from date.timezone = America/Los_Angeles to date.timezone = Europe/Paris in php.ini file that is in

opt/bitnami/php/etc

The file is modified I have permission to do it and if I do cat php.ini | grep date.timezone I get ;

http://php.net/date.timezone

date.timezone = "Europe/Paris"

I have restarted apache with

sudo /opt/bitnami/ctlscript.sh restart apache

But the time is still wrong. Besides, if I use phpinfo(), date.timezone is also wrong: America/Los_Angeles

Do I need to restart something more? What more I have to do to get the correct time?

Peter Pan
  • 23,476
  • 4
  • 25
  • 43
Adrián Rodriguez
  • 430
  • 11
  • 26

1 Answers1

0

Try date_default_timezone_set() in the beginning of your script: date_default_timezone_set('Europe/Paris');

Hope it helps.

Ren
  • 330
  • 6
  • 23
  • Now the time is 2 hours more, any idea? I have read that using the date_default_timezone_set() was worse option than modifying the php.ini file because maybe you have to run that function in many places, what do you think? – Adrián Rodriguez May 04 '16 at 09:03
  • Yes, you are right, this was just for fix. Try using echo ini_get('date.timezone') to print out current setup timezone. If it reads wrong, perhaps you edited a wrong ini file. – Ren May 04 '16 at 09:15
  • That is what I was talking about with @Pavel Petrov but following phpinfo() output I am not editing the wrong file. – Adrián Rodriguez May 04 '16 at 10:01
  • 1
    I've a webserver in Canada, used by Brasilian users. Ren answer is the right one. On my main include fle (included in all pages), I have: date_default_timezone_set('America/Sao_Paulo'); so you can do the same with Europe Paris. You must also use something like $ret = setlocale(LC_ALL, "pt_BR.utf-8"); (in my case Portuges from Brasil) in order that string functions work with the language you want. – Peter May 05 '16 at 01:04