PHP date function time zone problem and solution to incorrect time output

WBOY
Release: 2016-07-25 08:59:35
Original
1196 people have browsed it
This article introduces the solution to the time zone problem of the date function in PHP, which causes the output time to be incorrect. Friends in need can refer to it.

Problem: echo date('o-m-j H:i'); The output result is 8 hours different from the local time. Cause: The time zone is not set correctly. Solution: Method 1. Join

date_default_timezone_set('Asia/Shanghai');

Method 2, modify php.ini

[Date] ; Defines the default timezone used by the date functions date.timezone = PRC Note: PRC stands for Sinochem People’s Republic of China

Test it yourself, you will know after a try, and you can easily solve the date function time zone problem.



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