<?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>Dominic.Xu&#039;s 博客 &#187; 时区</title>
	<atom:link href="http://xuplus.com/article/tag/%e6%97%b6%e5%8c%ba/feed" rel="self" type="application/rss+xml" />
	<link>http://xuplus.com</link>
	<description>Web 2.0 生活</description>
	<lastBuildDate>Wed, 24 Aug 2011 05:26:12 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>[Hack]更改article模组输出feed时时间不对的缺陷</title>
		<link>http://xuplus.com/article/2007/07/a48.html</link>
		<comments>http://xuplus.com/article/2007/07/a48.html#comments</comments>
		<pubDate>Thu, 26 Jul 2007 01:32:10 +0000</pubDate>
		<dc:creator>Dominic</dc:creator>
				<category><![CDATA[XOOPS]]></category>
		<category><![CDATA[article]]></category>
		<category><![CDATA[feed]]></category>
		<category><![CDATA[Hack]]></category>
		<category><![CDATA[时区]]></category>

		<guid isPermaLink="false">http://xuplus.com/?p=48</guid>
		<description><![CDATA[服务时区设置为+8，在命令行行下显示正常，XOOPS中设置服务器所在时区为+0800，可article输出的feed时时间却怎么也不对，导致outlookRSS订阅中显示的文章时间也不对均为GMT+1600时区，哪有这样的时区哦，时区范围GMT-1200～GMT+1200。 修改方法如下： 1、修改htdocs\modules\article\class\feedcreator.class.php文件中739行附近FeedDate类的构造函数FeedDate如下： 1: function FeedDate($dateString="") { 2: $tzOffset = 0; 3: if ($dateString=="") $dateString = date("r"); 4:   5: //if (is_integer($dateString)) { 6: if (is_numeric($dateString)) { 7: $this-&#62;unix = $dateString; 8: return; 9: } 10: //Hack By XuYong 调整日期格式 11: if (preg_match("~(?:(?:Mon&#124;Tue&#124;Wed&#124;Thu&#124;Fri&#124;Sat&#124;Sun),\\s+)?(\\d{1,2})\\s+([a-zA-Z]{3})\\s+(\\d{4})\\s+(\\d{2}):(\\d{2}):(\\d{2})\\s+(.*)~",$dateString,$matches)) { 12: $months = Array("Jan"=&#62;1,"Feb"=&#62;2,"Mar"=&#62;3,"Apr"=&#62;4,"May"=&#62;5,"Jun"=&#62;6,"Jul"=&#62;7,"Aug"=&#62;8,"Sep"=&#62;9,"Oct"=&#62;10,"Nov"=&#62;11,"Dec"=&#62;12); 13: $this-&#62;unix = gmmktime($matches[4],$matches[5],$matches[6],$months[$matches[2]],$matches[1],$matches[3]); 14: if (substr($matches[7],0,1)=='+' [...]]]></description>
			<content:encoded><![CDATA[<p>服务时区设置为+8，在命令行行下显示正常，XOOPS中设置服务器所在时区为+0800，可article输出的feed时时间却怎么也不对，导致outlookRSS订阅中显示的文章时间也不对均为GMT+1600<a href="http://xuplus.com/article/tag/%e6%97%b6%e5%8c%ba" class="st_tag internal_tag" rel="tag" title="标签 时区 下的日志">时区</a>，哪有这样的时区哦，时区范围GMT-1200～GMT+1200。</p>
<p>修改方法如下：</p>
<p>1、修改htdocs\modules\<a href="http://xuplus.com/article/tag/article" class="st_tag internal_tag" rel="tag" title="标签 article 下的日志">article</a>\class\feedcreator.class.php文件中739行附近FeedDate类的构造函数FeedDate如下：</p>
<p style="font-size: 8pt; margin: 20px 0px 10px; overflow: auto; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4; border: gray 1px solid; padding: 4px">
<p style="font-size: 8pt; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4; border-style: none; padding: 0px">
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: white; border-style: none; padding: 0px"><span style="color: #606060">   1:</span> <span style="color: #0000ff">function</span> FeedDate($dateString=<span style="color: #006080">""</span>) {</pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4; border-style: none; padding: 0px"><span style="color: #606060">   2:</span>     $tzOffset = 0;</pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: white; border-style: none; padding: 0px"><span style="color: #606060">   3:</span>     <span style="color: #0000ff">if</span> ($dateString==<span style="color: #006080">""</span>) $dateString = date(<span style="color: #006080">"r"</span>);</pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4; border-style: none; padding: 0px"><span style="color: #606060">   4:</span>  </pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: white; border-style: none; padding: 0px"><span style="color: #606060">   5:</span>     <span style="color: #008000">//if (is_integer($dateString)) {</span></pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4; border-style: none; padding: 0px"><span style="color: #606060">   6:</span>     <span style="color: #0000ff">if</span> (is_numeric($dateString)) {</pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: white; border-style: none; padding: 0px"><span style="color: #606060">   7:</span>         $<span style="color: #0000ff">this</span>-&gt;unix = $dateString;</pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4; border-style: none; padding: 0px"><span style="color: #606060">   8:</span>         <span style="color: #0000ff">return</span>;</pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: white; border-style: none; padding: 0px"><span style="color: #606060">   9:</span>     }</pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4; border-style: none; padding: 0px"><span style="color: #606060">  10:</span>    <span style="color: #008000">//<a href="http://xuplus.com/article/tag/hack" class="st_tag internal_tag" rel="tag" title="标签 Hack 下的日志">Hack</a> By XuYong 调整日期格式</span></pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: white; border-style: none; padding: 0px"><span style="color: #606060">  11:</span>     <span style="color: #0000ff">if</span> (preg_match(<span style="color: #006080">"~(?:(?:Mon|Tue|Wed|Thu|Fri|Sat|Sun),\\s+)?(\\d{1,2})\\s+([a-zA-Z]{3})\\s+(\\d{4})\\s+(\\d{2}):(\\d{2}):(\\d{2})\\s+(.*)~"</span>,$dateString,$matches)) {</pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4; border-style: none; padding: 0px"><span style="color: #606060">  12:</span>         $months = Array(<span style="color: #006080">"Jan"</span>=&gt;1,<span style="color: #006080">"Feb"</span>=&gt;2,<span style="color: #006080">"Mar"</span>=&gt;3,<span style="color: #006080">"Apr"</span>=&gt;4,<span style="color: #006080">"May"</span>=&gt;5,<span style="color: #006080">"Jun"</span>=&gt;6,<span style="color: #006080">"Jul"</span>=&gt;7,<span style="color: #006080">"Aug"</span>=&gt;8,<span style="color: #006080">"Sep"</span>=&gt;9,<span style="color: #006080">"Oct"</span>=&gt;10,<span style="color: #006080">"Nov"</span>=&gt;11,<span style="color: #006080">"Dec"</span>=&gt;12);</pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: white; border-style: none; padding: 0px"><span style="color: #606060">  13:</span>         $<span style="color: #0000ff">this</span>-&gt;unix = gmmktime($matches[4],$matches[5],$matches[6],$months[$matches[2]],$matches[1],$matches[3]);</pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4; border-style: none; padding: 0px"><span style="color: #606060">  14:</span>         <span style="color: #0000ff">if</span> (substr($matches[7],0,1)==<span style="color: #006080">'+'</span> OR substr($matches[7],0,1)==<span style="color: #006080">'-'</span>) {</pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: white; border-style: none; padding: 0px"><span style="color: #606060">  15:</span>             $tzOffset = (substr($matches[7],0,3) * 60 + substr($matches[7],-2)) * 60;</pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4; border-style: none; padding: 0px"><span style="color: #606060">  16:</span>         } <span style="color: #0000ff">else</span> {</pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: white; border-style: none; padding: 0px"><span style="color: #606060">  17:</span>             <span style="color: #0000ff">if</span> (strlen($matches[7])==1) {</pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4; border-style: none; padding: 0px"><span style="color: #606060">  18:</span>                 $oneHour = 3600;</pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: white; border-style: none; padding: 0px"><span style="color: #606060">  19:</span>                 $ord = ord($matches[7]);</pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4; border-style: none; padding: 0px"><span style="color: #606060">  20:</span>                 <span style="color: #0000ff">if</span> ($ord &lt; ord(<span style="color: #006080">"M"</span>)) {</pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: white; border-style: none; padding: 0px"><span style="color: #606060">  21:</span>                     $tzOffset = (ord(<span style="color: #006080">"A"</span>) - $ord - 1) * $oneHour;</pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4; border-style: none; padding: 0px"><span style="color: #606060">  22:</span>                 } elseif ($ord &gt;= ord(<span style="color: #006080">"M"</span>) AND $matches[7]!=<span style="color: #006080">"Z"</span>) {</pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: white; border-style: none; padding: 0px"><span style="color: #606060">  23:</span>                     $tzOffset = ($ord - ord(<span style="color: #006080">"M"</span>)) * $oneHour;</pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4; border-style: none; padding: 0px"><span style="color: #606060">  24:</span>                 } elseif ($matches[7]==<span style="color: #006080">"Z"</span>) {</pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: white; border-style: none; padding: 0px"><span style="color: #606060">  25:</span>                     $tzOffset = 0;</pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4; border-style: none; padding: 0px"><span style="color: #606060">  26:</span>                 }</pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: white; border-style: none; padding: 0px"><span style="color: #606060">  27:</span>             }</pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4; border-style: none; padding: 0px"><span style="color: #606060">  28:</span>             <span style="color: #0000ff">switch</span> ($matches[7]) {</pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: white; border-style: none; padding: 0px"><span style="color: #606060">  29:</span>                 <span style="color: #0000ff">case</span> <span style="color: #006080">"UT"</span>:</pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4; border-style: none; padding: 0px"><span style="color: #606060">  30:</span>                 <span style="color: #0000ff">case</span> <span style="color: #006080">"GMT"</span>:    $tzOffset = 0;</pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: white; border-style: none; padding: 0px"><span style="color: #606060">  31:</span>             }</pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4; border-style: none; padding: 0px"><span style="color: #606060">  32:</span>         }</pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: white; border-style: none; padding: 0px"><span style="color: #606060">  33:</span></pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4; border-style: none; padding: 0px"><span style="color: #606060">  34:</span>         $tzOffset += date(<span style="color: #006080">"Z"</span>,0);</pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: white; border-style: none; padding: 0px"><span style="color: #606060">  35:</span>         $<span style="color: #0000ff">this</span>-&gt;unix += $tzOffset;</pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4; border-style: none; padding: 0px"><span style="color: #606060">  36:</span>  </pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: white; border-style: none; padding: 0px"><span style="color: #606060">  37:</span>         <span style="color: #0000ff">if</span> (TIME_ZONE!=<span style="color: #006080">""</span>)</pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4; border-style: none; padding: 0px"><span style="color: #606060">  38:</span>         {</pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: white; border-style: none; padding: 0px"><span style="color: #606060">  39:</span>             $server_TZ = abs(intval($GLOBALS[<span style="color: #006080">'xoopsConfig'</span>][<span style="color: #006080">'server_TZ'</span>] * 3600.0));</pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4; border-style: none; padding: 0px"><span style="color: #606060">  40:</span>             $<span style="color: #0000ff">this</span>-&gt;unix += ($server_TZ - date(<span style="color: #006080">"Z"</span>, 0)) % 43200;</pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: white; border-style: none; padding: 0px"><span style="color: #606060">  41:</span>         }</pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4; border-style: none; padding: 0px"><span style="color: #606060">  42:</span>  </pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: white; border-style: none; padding: 0px"><span style="color: #606060">  43:</span>         <span style="color: #0000ff">return</span>;</pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4; border-style: none; padding: 0px"><span style="color: #606060">  44:</span>     }</pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: white; border-style: none; padding: 0px"><span style="color: #606060">  45:</span>     <span style="color: #0000ff">if</span> (preg_match(<span style="color: #006080">"~(\\d{4})-(\\d{2})-(\\d{2})T(\\d{2}):(\\d{2}):(\\d{2})(.*)~"</span>,$dateString,$matches)) {</pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4; border-style: none; padding: 0px"><span style="color: #606060">  46:</span>         $<span style="color: #0000ff">this</span>-&gt;unix = gmmktime($matches[4],$matches[5],$matches[6],$matches[2],$matches[3],$matches[1]);</pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: white; border-style: none; padding: 0px"><span style="color: #606060">  47:</span>         <span style="color: #0000ff">if</span> (substr($matches[7],0,1)==<span style="color: #006080">'+'</span> OR substr($matches[7],0,1)==<span style="color: #006080">'-'</span>) {</pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4; border-style: none; padding: 0px"><span style="color: #606060">  48:</span>             $tzOffset = (substr($matches[7],0,3) * 60 + substr($matches[7],-2)) * 60;</pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: white; border-style: none; padding: 0px"><span style="color: #606060">  49:</span>         } <span style="color: #0000ff">else</span> {</pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4; border-style: none; padding: 0px"><span style="color: #606060">  50:</span>             <span style="color: #0000ff">if</span> ($matches[7]==<span style="color: #006080">"Z"</span>) {</pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: white; border-style: none; padding: 0px"><span style="color: #606060">  51:</span>                 $tzOffset = 0;</pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4; border-style: none; padding: 0px"><span style="color: #606060">  52:</span>             }</pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: white; border-style: none; padding: 0px"><span style="color: #606060">  53:</span>         }</pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4; border-style: none; padding: 0px"><span style="color: #606060">  54:</span>         $tzOffset += date(<span style="color: #006080">"Z"</span>,0);</pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: white; border-style: none; padding: 0px"><span style="color: #606060">  55:</span>         $<span style="color: #0000ff">this</span>-&gt;unix += $tzOffset;</pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4; border-style: none; padding: 0px"><span style="color: #606060">  56:</span>  </pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: white; border-style: none; padding: 0px"><span style="color: #606060">  57:</span>         <span style="color: #0000ff">if</span> (TIME_ZONE!=<span style="color: #006080">""</span>)</pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4; border-style: none; padding: 0px"><span style="color: #606060">  58:</span>         {</pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: white; border-style: none; padding: 0px"><span style="color: #606060">  59:</span>             $server_TZ = abs(intval($GLOBALS[<span style="color: #006080">'xoopsConfig'</span>][<span style="color: #006080">'server_TZ'</span>] * 3600.0));</pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4; border-style: none; padding: 0px"><span style="color: #606060">  60:</span>             $<span style="color: #0000ff">this</span>-&gt;unix += ($server_TZ - date(<span style="color: #006080">"Z"</span>, 0)) % 43200;</pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: white; border-style: none; padding: 0px"><span style="color: #606060">  61:</span>         }</pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4; border-style: none; padding: 0px"><span style="color: #606060">  62:</span>         <span style="color: #0000ff">return</span>;</pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: white; border-style: none; padding: 0px"><span style="color: #606060">  63:</span>     }</pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4; border-style: none; padding: 0px"><span style="color: #606060">  64:</span>     $<span style="color: #0000ff">this</span>-&gt;unix = 0;</pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: white; border-style: none; padding: 0px"><span style="color: #606060">  65:</span> }</pre>
<p><font size="3">2、修改htdocs\modules\article\class\xml.php文件58行，</font></p>
<p><font size="3">原来为：</font></p>
<p>$TIME_ZONE = $prefix.date(“H:i”, $server_TZ);</p>
<p><font size="3">修改为：</font></p>
<p>$TIME_ZONE = $prefix.date(“H:i”, ($server_TZ &#8211; date(“Z”, 0)) % 43200); //Hack By XuYong 调整时区显示，防止出现+1600时区</p>

	标签： <a href="http://xuplus.com/article/tag/article" title="article" rel="tag">article</a>, <a href="http://xuplus.com/article/tag/feed" title="feed" rel="tag">feed</a>, <a href="http://xuplus.com/article/tag/hack" title="Hack" rel="tag">Hack</a>, <a href="http://xuplus.com/article/tag/xoops" title="XOOPS" rel="tag">XOOPS</a>, <a href="http://xuplus.com/article/tag/%e6%97%b6%e5%8c%ba" title="时区" rel="tag">时区</a><br />
]]></content:encoded>
			<wfw:commentRss>http://xuplus.com/article/2007/07/a48.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>cnBeta订阅时区不对问题及linux下时区设置兼容性问题，慎用CST时区</title>
		<link>http://xuplus.com/article/2007/04/a20.html</link>
		<comments>http://xuplus.com/article/2007/04/a20.html#comments</comments>
		<pubDate>Thu, 26 Apr 2007 02:59:58 +0000</pubDate>
		<dc:creator>Dominic</dc:creator>
				<category><![CDATA[生活叫吠]]></category>
		<category><![CDATA[网站管理]]></category>
		<category><![CDATA[cnBeta]]></category>
		<category><![CDATA[CST]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[时区]]></category>
		<category><![CDATA[时间不对]]></category>
		<category><![CDATA[订阅]]></category>

		<guid isPermaLink="false">http://xuplus.com/?p=20</guid>
		<description><![CDATA[cnBeta是我非常喜爱的IT资讯站，装上Outlook 2007之后就用Outlook来完成订阅工作了，但是郁闷的是他的订阅条目的时间老是比当前时间早一些，动不动时间就是明天的了。打开http://www.cnbeta.com/backend.php页面代码发现里面的时区完全不对，不符合RSS2.0规范，RSS标准时区表示方法是GMT+0800这种格式，而cnbeta采用的是CST时区，很多unix下中国时区（Asia/Shanghai）都是用CST表示的。但是这个表示方法非常不合理，CST实际上表示以下四种时区： CST Central Standard Time (USA) UTC-6:00 （美国)中部标准时间 CST Central Standard Time (Australia) UTC+10:30 中澳大利亚标准时间 CST China Standard Time UTC+8:00 中国沿海时间(北京时间) CST Cuba Standard Time UTC-4:00 古巴标准时间 在unix下通过/etc/localtime这个硬连接指向的/usr/share/zoneinfo下的时区文件表示当前的真正时区。比如/etc/localtime指向了/usr/share/zoneinfo/Asia/Shanghai这个文件的时候，CST就代表了中国标准时间。但是很多语言的时间函数库根本不做这个判断，往往就是用一个独立的时区配置文件做时区关键字和GMT的转换。因此很多系统里面CST都变成了GMT-6，也就是美国中部时间。所以采用CST作为时区设置就会有兼容性的问题了。 在Windows中更是如此，所以订阅老是相差14个小时UTC-0600的现在不就是现在之后的14个小时吗。最根本的解决方法应该是改变unix服务器的时区，采用GMT+0800时区或者UTC+0800。 实际上中国标准时间（GMT+0800）的正确缩写是CCT，而不是CST。 更改linux服务器时区方法是：在/usr/share/zoneinfo/目录下,找到期望的时区,拷贝覆盖/etc/localtime ,然后reboot即可得到新的时区 查询、修改时间方式：  # hwclock命令 -r 查询BIOS时间 -w 将Linux内核时间写入BIOS  # date命令 -s 更改时间或日期 完成修改时区的工作之后可以通过#ntpdate命令来根据NTP服务器更新本地时间。 XOOPS的订阅也有时间问题，但我解决了，改天整理以下再发布。站长们检查一下网站订阅链接的时区是否正确吧。 标签： cnBeta, CST, linux, 时区, 时间不对, 订阅]]></description>
			<content:encoded><![CDATA[<p><font size="3"><a href="http://www.cnbeta.com">cnBeta</a>是我非常喜爱的IT资讯站，装上Outlook 2007之后就用Outlook来完成订阅工作了，但是郁闷的是他的订阅条目的时间老是比当前时间早一些，动不动时间就是明天的了。打开<a href="http://www.cnbeta.com/backend.php">http://www.cnbeta.com/backend.php</a>页面代码发现里面的时区完全不对，不符合RSS2.0规范，RSS标准时区表示方法是GMT+0800这种格式，而cnbeta采用的是CST时区，很多unix下中国时区（Asia/Shanghai）都是用CST表示的。但是这个表示方法非常不合理，CST实际上表示以下四种时区：</font></p>
<p><font size="3" style="background-color: #ffffcc"><a href="http://xuplus.com/article/tag/cst" class="st_tag internal_tag" rel="tag" title="标签 CST 下的日志">CST</a> Central Standard Time (USA) UTC-6:00 （美国)中部标准时间</font></p>
<p><font size="3" style="background-color: #ffffcc">CST Central Standard Time (Australia) UTC+10:30 中澳大利亚标准时间</font></p>
<p><font size="3" style="background-color: #ffffcc">CST China Standard Time UTC+8:00 中国沿海时间(北京时间)</font></p>
<p><font size="3" style="background-color: #ffffcc">CST Cuba Standard Time UTC-4:00 古巴标准时间</font></p>
<p><font size="3">在unix下通过/etc/localtime这个硬连接指向的/usr/share/zoneinfo下的时区文件表示当前的真正时区。比如/etc/localtime指向了/usr/share/zoneinfo/Asia/Shanghai这个文件的时候，CST就代表了中国标准时间。但是很多语言的时间函数库根本不做这个判断，往往就是用一个独立的时区配置文件做时区关键字和GMT的转换。因此很多系统里面CST都变成了GMT-6，也就是美国中部时间。所以采用CST作为时区设置就会有兼容性的问题了。</font></p>
<p><font size="3">在Windows中更是如此，所以订阅老是相差14个小时UTC-0600的现在不就是现在之后的14个小时吗。最根本的解决方法应该是改变unix服务器的时区，采用GMT+0800时区或者UTC+0800。</font></p>
<p><font size="3">实际上中国标准时间（GMT+0800）的正确缩写是CCT，而不是CST。</font></p>
<p><font size="3">更改linux服务器时区方法是：<font color="#ff0000">在/usr/share/zoneinfo/目录下,找到期望的时区,拷贝覆盖/etc/localtime ,然后reboot即可得到新的时区</font></font></p>
<p><font size="3"><font color="#ff0000"><font color="#000000">查询、修改时间方式： <br />
</font></font></font><font size="3"><font color="#ff0000"><font color="#000000"><font color="#ff0000"># hwclock<font color="#000000">命令</font> -r <font color="#000000">查询BIOS时间</font> -w <font color="#000000">将Linux内核时间写入BIOS</font> <br />
# date<font color="#000000">命令</font> -s </font><font color="#000000">更改时间或日期</font><br />
</font></font></font></p>
<p><font size="3"><font color="#ff0000"><font color="#000000">完成修改时区的工作之后可以通过<font color="#ff0000">#ntpdate</font>命令来根据NTP服务器更新本地时间。</font></font></font></p>
<p><font size="3"><font color="#ff0000"><font color="#000000">XOOPS的订阅也有时间问题，但我解决了，改天整理以下再发布。站长们检查一下网站订阅链接的时区是否正确吧。</font></font></font></p>

	标签： <a href="http://xuplus.com/article/tag/cnbeta" title="cnBeta" rel="tag">cnBeta</a>, <a href="http://xuplus.com/article/tag/cst" title="CST" rel="tag">CST</a>, <a href="http://xuplus.com/article/tag/linux" title="linux" rel="tag">linux</a>, <a href="http://xuplus.com/article/tag/%e6%97%b6%e5%8c%ba" title="时区" rel="tag">时区</a>, <a href="http://xuplus.com/article/tag/%e6%97%b6%e9%97%b4%e4%b8%8d%e5%af%b9" title="时间不对" rel="tag">时间不对</a>, <a href="http://xuplus.com/article/tag/%e8%ae%a2%e9%98%85" title="订阅" rel="tag">订阅</a><br />
]]></content:encoded>
			<wfw:commentRss>http://xuplus.com/article/2007/04/a20.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

