I set the right server time with the help of this tutorial: https://www.digitalocean.com/community/tutorials/how-to-set-up-time-synchronization-on-ubuntu-16-04
When I type “date” in the console, the correct time is now shown. But the PHP date(‘H:i’) command still shows 2 hours earlier. I have reset Apache2.
How can this happen and what can I do about it?
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.
Thanks again for your help! This is interesting. timedetectl was already set to Europe/Amsterdam, but this is the result:
So the local time is correct, but php seems to use the Universal or RTC time in the time() function. Now I found the PHP localtime() function: https://www.w3schools.com/php/func_date_localtime.asp
But this code:
even gives this result:
So the localtime() function doesn’t seem to do anything. (changing back the timezone in php.ini from Detroid to Amsterdam doesn’t have any effect on the output above (didn’t forget to restart Apache)).
Hi @KFSys ,
Thanks for your reply! So as a test, I changed it to Detroid, this gives the same effect; this is the phpinfo():
And the time is still 2 hours behind our local time so the change seems to have no effect…
Thanks,
Hi KFSys, this is the timezone part in phpinfo():
So date.timezone seems correct, maybe it’s going wrong in the values above it?