Set System PHP Timezone for Centos Linux systems

Posted on June 02, 2013

Newer versions of PHP on Centos (or Linux) systems complain if a time zone is not set on php.ini. This is a handy little command to set it for you.

TIMEZONE=$([ -f /etc/timezone ] && cat /etc/timezone | sed "s/\//\\\\\//g")
sudo sed -i".bak" "s/^\;date\.timezone.*$/date\.timezone = \"${TIMEZONE}\" /g" /etc/php.ini

Leave a Reply

Your email address will not be published.

Contact Us

Have a question? Send us a message. We'll get back to you soon.

captcha

Share
Tweet
Pin
Share