Linux PHP MySQL Time zone Setup method _php Tutorial

Source: Internet
Author: User
This article to give your classmates about the Linux PHP time zone setting method in detail, I hope this method will help you.

In the lamp environment, the ideal situation is the Linux PHP MySQL time zone is set consistent, otherwise the program is very prone to some quirks "timing" problem. Suppose you set the time zone to: "Asia/shanghai"

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


Cp-f/usr/share/zoneinfo/asia/shanghai/etc/localtime

2. Set the time zone in MySQL

Edit the MySQL configuration file: My.cnf/my.ini, under [Mysqld], add:

Default-time-zone = ' the ' "

In fact, if the time zone for MySQL's OS is set correctly, you can not set the time zone in MySQL, because the time zone of the OS is automatically used when the MySQL service starts.

3. Set the time zone in PHP

In PHP config file php.ini:

1 Date.timezone = "Asia/shanghai"

After Setup, it is a good idea to restart the system.

If it is a purchased web space, there is no permission to configure the time zone in Linux PHP MySQL. That's fine, just set the time zone in the PHP script that corresponds to the OS, because MySQL uses the OS's time zone by default. Assuming that the OS's time zone is ' Asia/shanghai ', use one of the following two statements:


Ini_set (' Date.timezone ', ' Asia/shanghai ');

Date_default_timezone_set (' Asia/shanghai ');

http://www.bkjia.com/PHPjc/628621.html www.bkjia.com true http://www.bkjia.com/PHPjc/628621.html techarticle This article to give your classmates about the Linux PHP time zone setting method in detail, I hope this method will help you. In the lamp environment, the ideal situation is when Linux PHP mysql ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.