Detailed explanation of Linux PHP MySQL time zone setting method_PHP tutorial

WBOY
Release: 2016-07-13 17:16:43
Original
950 people have browsed it

This article will introduce to you the detailed explanation of the Linux PHP MySQL time zone setting method. I hope this method will be helpful to you.

In the LAMP environment, the ideal situation is that the time zones of Linux, PHP, and MySQL are all set to be consistent. Otherwise, the program is prone to some unexpected [time difference] problems. Assume that the time zone is set to: "Asia/Shanghai"

1. Set the time zone on Linux, taking CentOS5.5 as an example:


cp -f /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

2. Set time zone in MySQL

Edit the MySQL configuration file: my.cnf/my.ini, add:

under [mysqld]

default-time-zone = '+8:00'

In fact, if the time zone of the OS where MySQL is located has been set correctly, you do not need to set the time zone in MySQL, because when the MySQL service starts, it will automatically adopt the time zone of the OS.

3. Set time zone in PHP

In the PHP configuration file PHP.ini:

1 date.timezone = "Asia/Shanghai"

After setting up, it is best to restart the system.

If you purchased the web space, you do not have permission to configure the time zone in Linux PHP MySQL. That's easy to do, you just need to set the time zone corresponding to the OS in the PHP script, because MySQL uses the OS time zone by default. Assuming that the time zone of the OS is 'Asia/Shanghai', use one of the following two statements:


ini_set('date.timezone', 'Asia/Shanghai');

date_default_timezone_set('Asia/Shanghai');

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/628621.htmlTechArticleThis article will introduce you to the detailed explanation of the Linux PHP MySQL time zone setting method. I hope this method will be useful to all students. helped. In a LAMP environment, the ideal situation is Linux PHP MySQL...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!