<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>idv2 &#187; timezone</title>
	<atom:link href="http://tech.idv2.com/tag/timezone/feed/" rel="self" type="application/rss+xml" />
	<link>http://tech.idv2.com</link>
	<description>关注Web开发技术，关注Internet。</description>
	<lastBuildDate>Tue, 27 Jul 2010 12:54:54 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.5</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>[PHP]getdate()等时间函数的时区问题</title>
		<link>http://tech.idv2.com/2007/10/08/php-getdate-timezone/</link>
		<comments>http://tech.idv2.com/2007/10/08/php-getdate-timezone/#comments</comments>
		<pubDate>Mon, 08 Oct 2007 14:37:40 +0000</pubDate>
		<dc:creator>charlee</dc:creator>
				<category><![CDATA[web]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[timezone]]></category>

		<guid isPermaLink="false">http://tech.idv2.com/2007/10/08/php-getdate-timezone/</guid>
		<description><![CDATA[这两天一直被一个问题所困扰。同样的一段程序，在自己的机器上调试完全没有问题，放到服务器上时间显示就快了8个小时。显然这8个小时就差在时区设置上。我在自己的机器上写代码时，对timestamp进行了时区调整（$now += 8 * 3600）之后再进行getdate()转换，结果完全正确；放到服务器上执行，就要将时区调整代码去掉之后才正常。一时百思不得其解。
写了个小测试程序：先用 time() 取得当前时间戳，再用 getdate() 获取当前的小时、分、秒，分别放到开发环境和服务器上执行。结果很显然，服务器上显示的时间是正确的（22点显示为22点），而我的机器的时间是错误的（22点显示为14点）。从时区的角度来看，服务器使用了正确的CST时区（中国时区），而我的开发环境的时区则是UTC的。但开发环境操作系统是Windows，时区设置也正确，为什么会出错？
从窄多的blog上看到，通过date_default_timezone_set()函数可以设置默认时区名。天啊，居然有这样的函数，查了查资料发现它的反义函数date_default_timezone_get()，将这个函数分别在开发环境和服务器上执行，果然，我的时区设置为 UTC。
知道了原因就好修改了。打开开发环境中的 php.ini，找到 date.timezone，去掉注释并将其设置为 Asia/Chongqing，再运行，这次结果正确了。
]]></description>
			<content:encoded><![CDATA[<p>这两天一直被一个问题所困扰。同样的一段程序，在自己的机器上调试完全没有问题，放到服务器上时间显示就快了8个小时。显然这8个小时就差在时区设置上。我在自己的机器上写代码时，对timestamp进行了时区调整（$now += 8 * 3600）之后再进行getdate()转换，结果完全正确；放到服务器上执行，就要将时区调整代码去掉之后才正常。一时百思不得其解。</p>
<p>写了个小测试程序：先用 time() 取得当前时间戳，再用 getdate() 获取当前的小时、分、秒，分别放到开发环境和服务器上执行。结果很显然，服务器上显示的时间是正确的（22点显示为22点），而我的机器的时间是错误的（22点显示为14点）。从时区的角度来看，服务器使用了正确的CST时区（中国时区），而我的开发环境的时区则是UTC的。但开发环境操作系统是Windows，时区设置也正确，为什么会出错？</p>
<p>从<a href="http://www.zhaiduo.com/?p=56" target="_blank">窄多的blog</a>上看到，通过date_default_timezone_set()函数可以设置默认时区名。天啊，居然有这样的函数，查了查资料发现它的反义函数date_default_timezone_get()，将这个函数分别在开发环境和服务器上执行，果然，我的时区设置为 UTC。</p>
<p>知道了原因就好修改了。打开开发环境中的 php.ini，找到 date.timezone，去掉注释并将其设置为 Asia/Chongqing，再运行，这次结果正确了。</p>
]]></content:encoded>
			<wfw:commentRss>http://tech.idv2.com/2007/10/08/php-getdate-timezone/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
