date()方法读取时间戳的诡异有关问题!大家!

WBOY
Release: 2016-06-13 13:20:24
Original
954 people have browsed it

date()方法读取时间戳的诡异问题!!求助大家!!!
如有一个时间戳是:1343836800

(1)在我本地:

PHP code
<!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

-->
echo date('Y-m-d H:i:s', 1343836800);

Copy after login
Copy after login

输出:2012-08-01 16:00:00

(2)在公司的服务器上:
PHP code
<!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

-->
echo date('Y-m-d H:i:s', 1343836800);

Copy after login
Copy after login

输出:2012-08-02 00:00:00

为什么同样一个时间戳输出两个值不一样啊???

------解决方案--------------------
你2个时间相差8小时,肯定是时区设置的问题。
------解决方案--------------------
你本地环境是格林威治标准时间。设置下时区:
date_default_timezone_set('PRC');
echo date('Y-m-d H:i:s', 1343836800);
Related labels:
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