4

Ok I have a VPS running Ubuntu Server 12.10 32Bit and I need to set the timezone in my PHP.ini file so my PHP Script's time and date features will work (I am trying to setup ModX) I have tried to go to /etc/php5 and change it in different files and it won't work. How do I change PHP's timezone. Also everything in the .ini file has a ; in front of it is that a comment or what? Also I forgot to mention that my webserver in installed via tasksel as LAMP.

2
  • Have you tried restarting your server ? Feb 23, 2013 at 17:31
  • I have not restarted my serer but I restarted the Apache service. Feb 23, 2013 at 17:33

2 Answers 2

5

find your php.ini and change the value of date.timezone = Europe/Berlin

Edit(Thanks to @awashburn for his comment): the php-cli's php.ini file is different then apache2's php.ini file. I suggest symbolic linking one to another to keep them in sync and avoid confusion!

7
  • Which .ini file do I use? Where is the file located for Apache2? Feb 23, 2013 at 17:32
  • I use xampp myself. but in your case I think it is in /etc, try t o search in your filesystem with find | grep php.ini Feb 23, 2013 at 17:34
  • Ok please refersh this page in 10 minutes as I am going to try /etc/apache2/php.ini then restart my VPS and see if that works. Feb 23, 2013 at 17:35
  • 1
    Note: the php-cli's php.ini file is different then apache2's php.ini file. I suggest symbolic linking one to another to keep them in sync and avoid confusion! Feb 15, 2014 at 19:43
  • 3
    this is the file he meant /etc/php5/apache2/php.ini
    – Zuko
    Feb 15, 2014 at 21:05
3

1) Find the right php.ini file

Apache

Create a file info.php with this content:

<?php 

phpinfo();

Then open the file from a web browser and find the row Loaded Configuration File.

CLI

Just run this command:

$ php --ini

2) Change the timezone value in the php.ini

Open the right php.ini file, search for the date.timezone = value (usually under the [Date] section), and set:

date.timezone = Europe/Berlin

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .