<?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>任海波博客 &#187; Locoy</title>
	<atom:link href="http://www.renhaibo.com/archives/tags/locoy/feed" rel="self" type="application/rss+xml" />
	<link>http://www.renhaibo.com</link>
	<description>路漫漫其修远兮，吾将上下而求索。</description>
	<lastBuildDate>Thu, 29 Jul 2010 17:23:59 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>wordpress 2.6.3火车发布接口中设置多时区并存</title>
		<link>http://www.renhaibo.com/archives/46.html</link>
		<comments>http://www.renhaibo.com/archives/46.html#comments</comments>
		<pubDate>Mon, 01 Dec 2008 15:59:17 +0000</pubDate>
		<dc:creator>Hypo</dc:creator>
				<category><![CDATA[WordPress]]></category>
		<category><![CDATA[Locoy]]></category>

		<guid isPermaLink="false">http://www.renhaibo.com/archives/46.html</guid>
		<description><![CDATA[上次写了《火车头wordpress 2.6.3 发布接口中时区的设置》发现，在浏览文章时显示的时间是正常的中国+8时区的时间，但在后台却不是这样的：明明是刚刚发布的文章，却显示是8个小时以前的。让海波再次迷惑了，但最终还是解决了，分享一下我的解决过程。

再次查看了SQL.PHP文件后找出了与时间有关的代码：
$showtime=date("Y-m-d H:i:s");
$tm=time();
$sql="INSERT INTO `".$table_prefix."posts` ( `post_author`, `post_date`, `post_date_gmt`, `post_content`, `post_title`, `post_category`, `post_excerpt`, `post_status`, `comment_status`, `ping_status`, `post_password`, `post_name`, `to_ping`, `pinged`, `post_modified`, `post_modified_gmt`, `post_content_filtered`, `post_parent`, `guid`, `menu_order`, `post_type`, `post_mime_type`, `comment_count`) VALUES (1, '$showtime', '$showtime', '$content', '$title', '$cid', '$summary', 'publish', 'open', 'open', '', '', '', '', '$showtime', '$showtime', '', 0, '', 0, 'post', '', 0)";
注意四个参数post_date、post_date_gmt、post_modified和post_modified_gmt，这四个参数的含义分别为发表时间、发表时间的格林威治时间、修改时间和修改时间的格林威治时间。
如下图，如果你在WP控制台上设置为非UTC（国际标准时间），如UTC+8，那么应该是post_date=post_date_gmt+8小时，post_modified=post_modified_gmt+8小时。但是从上述代码中可以看出，post_date、post_date_gmt、post_modified和post_modified_gmt都得到了$showtime这个值。所以在后台的显示就出现了问题。

在查找相关资料并测试了N次之后依然没能解决，海波只好抛弃了资料，胡乱试验，运气真好还真找到了一个很简单的方法，那就是设置两次时区并赋值给不通的参数，我的代码如下：
date_default_timezone_set("GMT");
$showtime=date("Y-m-d H:i:s");
$tm=time();
date_default_timezone_set("PRC");
$showtimeprc=date("Y-m-d [...]]]></description>
			<content:encoded><![CDATA[<p>上次写了<a href="http://www.renhaibo.com/archives/31.html">《火车头wordpress 2.6.3 发布接口中时区的设置》</a>发现，在浏览文章时显示的时间是正常的中国+8时区的时间，但在后台却不是这样的：明明是刚刚发布的文章，却显示是8个小时以前的。让<a href="http://www.renhaibo.com">海波</a>再次迷惑了，但最终还是解决了，分享一下我的解决过程。</p>
<p><span id="more-46"></span></p>
<p>再次查看了SQL.PHP文件后找出了与时间有关的代码：<br />
<span style="color: #ff0000;">$showtime</span>=date("Y-m-d H:i:s");<br />
$tm=time();<br />
$sql="INSERT INTO `".$table_prefix."posts` ( `post_author`, `<span style="color: #ff0000;">post_date</span>`, `<span style="color: #ff0000;">post_date_gmt</span>`, `post_content`, `post_title`, `post_category`, `post_excerpt`, `post_status`, `comment_status`, `ping_status`, `post_password`, `post_name`, `to_ping`, `pinged`, `<span style="color: #ff0000;">post_modified</span>`, `<span style="color: #ff0000;">post_modified_gmt</span>`, `post_content_filtered`, `post_parent`, `guid`, `menu_order`, `post_type`, `post_mime_type`, `comment_count`) VALUES (1, '<span style="color: #ff0000;">$showtime</span><span style="color: #000000;">'</span>, '<span style="color: #ff0000;">$showtime</span><span style="color: #000000;">'</span>, '$content', '$title', '$cid', '$summary', 'publish', 'open', 'open', '', '', '', '', '<span style="color: #ff0000;">$showtime</span><span style="color: #000000;">'</span>, '<span style="color: #ff0000;">$showtime</span><span style="color: #000000;">'</span>, '', 0, '', 0, 'post', '', 0)";</p>
<p>注意四个参数post_date、post_date_gmt、post_modified和post_modified_gmt，这四个参数的含义分别为发表时间、发表时间的格林威治时间、修改时间和修改时间的格林威治时间。</p>
<p>如下图，如果你在WP控制台上设置为非UTC（国际标准时间），如UTC+8，那么应该是post_date=post_date_gmt+8小时，post_modified=post_modified_gmt+8小时。但是从上述代码中可以看出，post_date、post_date_gmt、post_modified和post_modified_gmt都得到了$showtime这个值。所以在后台的显示就出现了问题。<br />
<img src="http://img.renhaibo.com/00046/1.jpg" alt="wordpress 2.6.3火车发布接口中设置多时区并存" title="wordpress 2.6.3火车发布接口中设置多时区并存" /></p>
<p>在查找相关资料并测试了N次之后依然没能解决，<a href="http://www.renhaibo.com">海波</a>只好抛弃了资料，胡乱试验，运气真好还真找到了一个很简单的方法，那就是设置两次时区并赋值给不通的参数，我的代码如下：<br />
<span style="color: #ff0000;"><span style="color: #0000ff;">date_default_timezone_set("GMT");</span><br />
</span><span style="color: #ff0000;">$showtime</span>=date("Y-m-d H:i:s");<br />
$tm=time();<br />
<span style="color: #0000ff;">date_default_timezone_set("PRC");</span><br />
<span style="color: #ff0000;">$showtimeprc</span>=date("Y-m-d H:i:s");<br />
$tm=time();<br />
$sql="INSERT INTO `".$table_prefix."posts` ( `post_author`, `<span style="color: #ff0000;">post_date</span>`, `<span style="color: #ff0000;">post_date_gmt</span>`, `post_content`, `post_title`, `post_category`, `post_excerpt`, `post_status`, `comment_status`, `ping_status`, `post_password`, `post_name`, `to_ping`, `pinged`, `<span style="color: #ff0000;">post_modified</span>`, `<span style="color: #ff0000;">post_modified_gmt</span>`, `post_content_filtered`, `post_parent`, `guid`, `menu_order`, `post_type`, `post_mime_type`, `comment_count`) VALUES (1, '<span style="color: #ff0000;">$showtimeprc</span><span style="color: #000000;">'</span>, <span style="color: #ff0000;"><span style="color: #000000;">'</span>$showtime</span><span style="color: #000000;">'</span>, '$content', '$title', '$cid', '$summary', 'publish', 'open', 'open', '', '', '', '', '<span style="color: #ff0000;">$showtimeprc</span><span style="color: #000000;">'</span>, '<span style="color: #ff0000;">$showtime</span><span style="color: #000000;">'</span>, '', 0, '', 0, 'post', '', 0)";</p>
<p>换上以上代码后，就完美解决了文章在普通页面和后台的显示时间的一致。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.renhaibo.com/archives/46.html/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>火车头wordpress 2.6.3 发布接口中时区的设置</title>
		<link>http://www.renhaibo.com/archives/31.html</link>
		<comments>http://www.renhaibo.com/archives/31.html#comments</comments>
		<pubDate>Tue, 11 Nov 2008 16:13:31 +0000</pubDate>
		<dc:creator>Hypo</dc:creator>
				<category><![CDATA[WordPress]]></category>
		<category><![CDATA[网络日志]]></category>
		<category><![CDATA[Locoy]]></category>

		<guid isPermaLink="false">http://www.renhaibo.com/archives/31.html</guid>
		<description><![CDATA[昨天体验了一把火车头采集器，标题内容等信息的采集规则都设置好了，但是发布到网站的文章时间却不正确，我没有在接口模板中设置时间呀。在仔细看了时间后发现，是格林威治时间，差8个小时，我用美国的空间，原来是时区设置的问题。

我用的是火车头官方发布的接口“wordpress 2.6.3 火车发布接口”，包含了接口文件“wordpress 2.6.3 火车采集解决方案.cwr”和免登陆的文件夹“locoy”，“locoy”中有三个文件“mysql.class.php、sql.php和wp-config.php”。简单说下使用方法，安装好火车头后，将“wordpress 2.6.3 火车采集解决方案.cwr”导入火车头的接口中，然后修改“sql.php”内的数据库信息为你网站的数据库信息，并将“locoy”传到网站根目录。
此问题中更改时区设置的简单方法，就是在“sql.php”的第一行“&#60;?php”后面加入一行代码：ini_set('date.timezone','Asia/Shanghai'); 就可以了。
看看吧发布时间已经改过来了。
官方版“wordpress 2.6.3 火车发布接口”下载地址：地址1 &#124; 地址2 &#124; 地址3，火车版本：火车采集器V2008免费版，自己去官方下载。
]]></description>
			<content:encoded><![CDATA[<p>昨天体验了一把火车头采集器，标题内容等信息的采集规则都设置好了，但是发布到网站的文章时间却不正确，我没有在接口模板中设置时间呀。在仔细看了时间后发现，是格林威治时间，差8个小时，我用美国的空间，原来是时区设置的问题。</p>
<p><span id="more-31"></span></p>
<p>我用的是火车头官方发布的接口“wordpress 2.6.3 火车发布接口”，包含了接口文件“wordpress 2.6.3 火车采集解决方案.cwr”和免登陆的文件夹“locoy”，“locoy”中有三个文件“mysql.class.php、sql.php和wp-config.php”。简单说下使用方法，安装好火车头后，将“wordpress 2.6.3 火车采集解决方案.cwr”导入火车头的接口中，然后修改“sql.php”内的数据库信息为你网站的数据库信息，并将“locoy”传到网站根目录。</p>
<p>此问题中更改时区设置的简单方法，就是在“sql.php”的第一行“&lt;?php”后面加入一行代码：<code><span style="color: #ff0000;">ini_set('date.timezone','Asia/Shanghai');</span> </code>就可以了。</p>
<p>看看吧发布时间已经改过来了。</p>
<p>官方版“wordpress 2.6.3 火车发布接口”下载地址：<a href="http://www.ziddu.com/downloadfile/2630416/wordpress2.6.3.zip.html">地址1</a> | <a href="http://www.namipan.com/downfile/wordpress%202.6.3%20%E7%81%AB%E8%BD%A6%E5%8F%91%E5%B8%83%E6%8E%A5%E5%8F%A3.zip/f49da9e48289ee3892c61174c1050b9b52b3858a3d1a0000">地址2</a> | <a href="http://bbs.locoy.com/spider-28356-1-1.html" target="_blank">地址3</a>，火车版本：火车采集器V2008免费版，自己去官方下载。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.renhaibo.com/archives/31.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
