<?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>Unix时间戳 &#8211; LPC影子技术分享</title>
	<atom:link href="https://www.mudbest.com/tag/unix%E6%97%B6%E9%97%B4%E6%88%B3/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.mudbest.com</link>
	<description>行影不离,忘之却步.</description>
	<lastBuildDate>Mon, 01 Oct 2012 13:44:39 +0000</lastBuildDate>
	<language>zh-Hans</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.1.1</generator>
	<item>
		<title>php时间戳和正常时间显示的转换</title>
		<link>https://www.mudbest.com/php%e6%97%b6%e9%97%b4%e6%88%b3%e5%92%8c%e6%ad%a3%e5%b8%b8%e6%97%b6%e9%97%b4%e6%98%be%e7%a4%ba%e7%9a%84%e8%bd%ac%e6%8d%a2/</link>
		
		<dc:creator><![CDATA[admin]]></dc:creator>
		<pubDate>Sat, 12 Feb 2011 08:29:50 +0000</pubDate>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Unix时间戳]]></category>
		<guid isPermaLink="false">http://blog.mudbest.com/?p=351</guid>

					<description><![CDATA[date(&#8220;Y-m-d H:i:s&#8221;,$time) 将时间戳转换 2011-02-12 ... <a title="php时间戳和正常时间显示的转换" class="read-more" href="https://www.mudbest.com/php%e6%97%b6%e9%97%b4%e6%88%b3%e5%92%8c%e6%ad%a3%e5%b8%b8%e6%97%b6%e9%97%b4%e6%98%be%e7%a4%ba%e7%9a%84%e8%bd%ac%e6%8d%a2/" aria-label="阅读 php时间戳和正常时间显示的转换">阅读更多</a>]]></description>
										<content:encoded><![CDATA[<p>date(&#8220;Y-m-d H:i:s&#8221;,$time)</p>
<p>将时间戳转换 2011-02-12 16:29:30<br />
$mktime 是时间戳<br />
例子: $nowtime = date(&#8220;Y-m-d H:i:s&#8221;,$mktime);</p>
<p>时间戳转正常日期有了,反之呢,把正常日期格式转为时间戳呢,请看如下代码：<span id="more-351"></span></p>
<pre class="brush: php; title: ; notranslate">
$year=((int)substr(&quot;2008-12-04&quot;,0,4));//取得年份

$month=((int)substr(&quot;2008-12-04&quot;,5,2));//取得月份

$day=((int)substr(&quot;2008-12-04&quot;,8,2));//取得几号

echo mktime(0,0,0,$month,$day,$year);
</pre>
<p>这样就能把正常日期转成时间戳了,这里如果有时分秒也是同理,</p>
<p>注意：php5.1以上时间戳会与实际时间相差8小时，解决办法如下<br />
1、最简单的方法就是不要用php5.1以上的版本&#8211;显然这是不可取的方法！！！</p>
<p>2、修改php.ini。打开php.ini查找date.timezone 去掉前面的分号= 后面加Asia/Shanghai，重启apache服务器即可&#8211;缺点就是如果程序<br />
放到别人的服务器上，不能修改php.ini，那就奈何不得了。</p>
<p>3、在程序中添加时间的初始化的语句的 即：“date_default_timezone_set(&#8220;Asia/Shanghai&#8221;); ”这个可以由程序员任意设置，我的推<br />
荐。<br />
时区标识符，大陆内地可用的值是：PRC，Asia/Chongqing ，Asia/Shanghai ，Asia/Urumqi （依次为中国，重庆，上海，乌鲁木齐） ，Etc/GMT-8，Asia/Harbin<br />
港台地区可用：Asia/Macao ，Asia/Hong_Kong ，Asia/Taipei （依次为澳门，香港，台北）<br />
还有新加坡：Asia/Singapore</p>
<p>这样就可以实现输出的是北京时间了。</p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
