问一上有关time()方法的有关问题

WBOY
Release: 2016-06-13 10:37:51
Original
863 people have browsed it

问一下有关time()方法的问题
1、time()获取的总是当前时区的时间戳吗?不管是否设置了时区。

PHP code
<!--Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->//我写了两个测试页面,两个页面获取的值相同://a.php:echo time();//b.phpdate_default_timezone_set('PRC');echo time();
Copy after login


2、time()这个方法是依照哪个时间获取的时间戳?
如我在WIN下,是参照工具栏中的WINDOWS时间吗?然后减去8*60*60?
在Linux下是参照硬件时钟还是软件时钟呢?

3、另外请问是不是php4不支持设置时区?
我们单位服务器配的是php4,然后在没有设置时区的情况下,直接“echo date('Y-m-d H:i:s');”,输出的也是正确的中国时间。

谢谢各位!

------解决方案--------------------
那是当然的
又仔细看了一下你原始的问题,你是对
echo time();
date_default_timezone_set('PRC');
echo time();
输出的结果相同有疑问对吧?
我 #1 的回复有矛盾,应该是 time 始终取得的是格林威治时间
date 函数才与时区有关

echo date('Y-m-d H:i:s');
date_default_timezone_set('PRC');
echo date('Y-m-d H:i:s');

就能看出区别了
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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!