(mt):Modify the default PHP timezone

  • This page was last modified on April 14, 2012, at 21:38.
The (mt) Community Wiki is a collaborative project. Any (mt) Media Temple customer or employee may contribute. Not all articles and/or content have been tested for accuracy by (mt) Media Temple.

For officially moderated and tested articles, be sure to visit our KnowledgeBase.

From (mt) Community Wiki

Contents

Overview

All (mt) Media Temple servers are located in one of two data centers, California, or Virginia, and the default PHP time zone for these servers depend on what data center they are in. However, some users may want their PHP applications to run in a different timezone. Making this modification is as simple as adding a single line to the php.ini file, and this wiki article will show you how.

This article is provided as a courtesy. Installing, configuring, and troubleshooting third-party applications is outside the scope of support provided by (mt) Media Temple. Please take a moment to review the Statement of Support.

Requirements

(dv) Dedicated-Virtual Server users should have root enabled, and be comfortable editing files via SSH.

It is assumed (ve) Server users are using a default installation of Apache, and the default php.ini location of /etc/php.ini.

Instructions

On the (gs) Grid-Service

Figure 1:Where to change the file name in the File Manager.
  1. Open the File Manager inside the AccountCenter.
  2. Choose the folder called etc.
  3. Click the file called php.ini.sample, it may also be called php.ini if you have edited this file before.
  4. Once the file is open, add the following to any blank line underneath [PHP]:
    /etc/php.ini
    date.timezone="Atlantic/Bermuda"
    Please note that this would set the timezone to Bermuda (-4 UTC), modify the timezone to whatever you would like it to be. For a list of timezones that PHP supports, visit the following PHP website.
  5. If the file is called php.ini.sample, change the file name to read php.ini (see Figure 1).
    If it is called php.ini, proceed to the next step.
  6. Press the "save changes" button.
  7. To verify the new timezone is working, set up and load a PHP Info page.
  8. You are done!

On the (ve) Server and (dv) Dedicated-Virtual Server

  1. Log into the server as root.
  2. Open up /etc/php.ini in your favorite text editor, and add the following to any blank line underneath [PHP]:
    /etc/php.ini
    date.timezone="Atlantic/Bermuda"
    Please note that this would set the timezone to Bermuda (-4 UTC), modify the timezone to whatever you would like it to be. For a list of timezones that PHP supports, visit the following PHP website.
  3. Save the file, and restart Apache:
    /etc/init.d/httpd restart
  4. To verify the new timezone is working, set up and load a PHP Info page.
  5. You are done!

Resources

PHP page about date and time configuration
List of supported PHP timezones