Time zone and hour system in PHP

Source: Internet
Author: User
In the afternoon, two problems were encountered: Incorrect display of the time zone, and the time inserted in CakePHP (in the datetime format) was always displayed as 12-digit. The solutions are as follows:

The first problem is as follows:

For PHP Time Zone errors, solve the problem ~~~
Author: mengshu enough Release Date: views:

264 from: http://www.phpx.com
Win2003, apache2, PhP5, and system time zone settings are fine, but my PHP determines that I am an international standard (GMT) instead of a Chinese Standard (GMT + 8 ), so I date ("Y-m-d G: I t", time () out of the hour part of the total less than the correct time 8 hours .... what is the problem with prawns? How can I modify it?
[Forum browsing] [Let me talk about two sentences] [print] [large] [medium] [small] [closed]

Related Comments
Author: mengshu enough Release Date: 2006-2-13
Start by yourself and wait for someone to answer ~~~
Author: yoryoue Release Date: 2006-2-13
Date ('Y-m-d G: I: t', strtotime ('+ 8 hour '))
Author: mengshu enough Release Date: 2006-2-13
Thanks to the answers from my friends upstairs, but it is not a cure for this problem...
Author: FAQ released on: 2006-2-13
Strange question: How can I change the PHP version to an experiment?
Author: mengshu enough Release Date: 2006-2-13
Finally, I found the answer ~~~~
From CC Spiderman's blog
From php5.1.0, the date. timezone option is added to PhP. ini, Which is disabled by default.

That is, the displayed time (no matter what php Command is used) is the Greenwich Mean Time.

The difference between the time and our time (Beijing time) is exactly 8 hours. In the following three ways, we can restore the normal time.

1. The simplest method is not to use php5.1 or a later version.

2. If it must be used and PHP. ini cannot be modified
Add date_default_timezone_set (XXX );
CP does not have this problem

3. Once and for all, only Php. ini can be modified. Open PHP. ini and find date. timezone. Remove the semicolon.
= Add XXX to the backend and restart the HTTP service (such as apache2 or IIS ).

For XXX, the available values in mainland China are: Asia/Chongqing, Asia/Shanghai, Asia/Urumqi (Chongqing, Shanghai, and Urumqi in sequence)
Available in Hong Kong and Taiwan regions: Asia/Macao, Asia/hong_kong, Asia/Taipei (in the order of Macao, Hong Kong, and Taipei)
Singapore: Asia/Singapore
Foreigners seem to have missed Beijing
Other available values are: ETC/GMT-8, Singapore, Hongkong, PRC
What is PRC? PRC is the People's Republic of China -_-
The above are all my documents from the PHP official documents to sort out the GMT-8 below the area, there may be omissions
You can check more regions on http://www.php.net/docs.php

Since the program will eventually convert the place name to the time zone for calculation, when you are not using the built-in area, the program will automatically use the Greenwich Mean Time

Author: getphp released on: 2006-2-13
Oh, it turns out so.
Author: chiyanqian released on: 2006-2-13
It turned out to be the case. No wonder I had a wrong time to get the system. It's okay to put it on the server. It turned out to be a PHP version problem!
Long knowledge
Total Comments 7/10 per page

The second problem is even more difficult to find. Later, with the help of experts, find the datetime format in/cake/libs/model/DBO/dbo_mysql.php and set h: I: after S is changed to H: I: S, the problem is solved. Later, I downloaded the latest CakePHP kernel and found that their development team had solved the problem.
Note the following before using cakephp2026.

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.