<?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>时间戳 &#8211; LPC影子技术分享</title>
	<atom:link href="https://www.mudbest.com/tag/%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 12:13:56 +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>常用时间戳函数</title>
		<link>https://www.mudbest.com/%e5%b8%b8%e7%94%a8%e6%97%b6%e9%97%b4%e6%88%b3%e5%87%bd%e6%95%b0/</link>
		
		<dc:creator><![CDATA[hkshadow]]></dc:creator>
		<pubDate>Wed, 31 Aug 2011 08:35:31 +0000</pubDate>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[时间戳]]></category>
		<guid isPermaLink="false">http://www.mudbest.com/?p=789</guid>

					<description><![CDATA[以下对时间处理的函数是经常用的。]]></description>
										<content:encoded><![CDATA[<p>以下对时间处理的函数是经常用的。<span id="more-789"></span></p>
<pre class="brush: php; title: ; notranslate">
&lt;?php
/**
 *  返回格林威治标准时间
 *
 * @param     string  $format  字符串格式
 * @param     string  $timest  时间基准
 * @return    string
 */
if ( ! function_exists('MyDate'))
{
    function MyDate($format='Y-m-d H:i:s', $timest=0)
    {
        global $cfg_cli_time;
        $addtime = $cfg_cli_time * 3600;
        if(empty($format))
        {
            $format = 'Y-m-d H:i:s';
        }
        return gmdate ($format, $timest+$addtime);
    }
}


/**
 * 从普通时间转换为Linux时间截
 *
 * @param     string   $dtime  普通时间
 * @return    string
 */
if ( ! function_exists('GetMkTime'))
{
    function GetMkTime($dtime)
    {
        if(!preg_match(&quot;/&#x5B;^0-9]/&quot;, $dtime))
        {
            return $dtime;
        }
        $dtime = trim($dtime);
        $dt = Array(1970, 1, 1, 0, 0, 0);
        $dtime = preg_replace(&quot;/&#x5B;\r\n\t]|日|秒/&quot;, &quot; &quot;, $dtime);
        $dtime = str_replace(&quot;年&quot;, &quot;-&quot;, $dtime);
        $dtime = str_replace(&quot;月&quot;, &quot;-&quot;, $dtime);
        $dtime = str_replace(&quot;时&quot;, &quot;:&quot;, $dtime);
        $dtime = str_replace(&quot;分&quot;, &quot;:&quot;, $dtime);
        $dtime = trim(preg_replace(&quot;/&#x5B; ]{1,}/&quot;, &quot; &quot;, $dtime));
        $ds = explode(&quot; &quot;, $dtime);
        $ymd = explode(&quot;-&quot;, $ds&#x5B;0]);
        if(!isset($ymd&#x5B;1]))
        {
            $ymd = explode(&quot;.&quot;, $ds&#x5B;0]);
        }
        if(isset($ymd&#x5B;0]))
        {
            $dt&#x5B;0] = $ymd&#x5B;0];
        }
        if(isset($ymd&#x5B;1])) $dt&#x5B;1] = $ymd&#x5B;1];
        if(isset($ymd&#x5B;2])) $dt&#x5B;2] = $ymd&#x5B;2];
        if(strlen($dt&#x5B;0])==2) $dt&#x5B;0] = '20'.$dt&#x5B;0];
        if(isset($ds&#x5B;1]))
        {
            $hms = explode(&quot;:&quot;, $ds&#x5B;1]);
            if(isset($hms&#x5B;0])) $dt&#x5B;3] = $hms&#x5B;0];
            if(isset($hms&#x5B;1])) $dt&#x5B;4] = $hms&#x5B;1];
            if(isset($hms&#x5B;2])) $dt&#x5B;5] = $hms&#x5B;2];
        }
        foreach($dt as $k=&gt;$v)
        {
            $v = preg_replace(&quot;/^0{1,}/&quot;, '', trim($v));
            if($v=='')
            {
                $dt&#x5B;$k] = 0;
            }
        }
        $mt = mktime($dt&#x5B;3], $dt&#x5B;4], $dt&#x5B;5], $dt&#x5B;1], $dt&#x5B;2], $dt&#x5B;0]);
        if(!empty($mt))
        {
              return $mt;
        }
        else
        {
              return time();
        }
    }
}


/**
 *  减去时间
 *
 * @param     int  $ntime  当前时间
 * @param     int  $ctime  减少的时间
 * @return    int
 */
if ( ! function_exists('SubDay'))
{
    function SubDay($ntime, $ctime)
    {
        $dayst = 3600 * 24;
        $cday = ceil(($ntime-$ctime)/$dayst);
        return $cday;
    }
}


/**
 *  增加天数
 *
 * @param     int  $ntime  当前时间
 * @param     int  $aday   增加天数
 * @return    int
 */
if ( ! function_exists('AddDay'))
{
    function AddDay($ntime, $aday)
    {
        $dayst = 3600 * 24;
        $oktime = $ntime + ($aday * $dayst);
        return $oktime;
    }
}


/**
 *  返回格式化(Y-m-d H:i:s)的是时间
 *
 * @param     int    $mktime  时间戳
 * @return    string
 */
if ( ! function_exists('GetDateTimeMk'))
{
    function GetDateTimeMk($mktime)
    {
        return MyDate('Y-m-d H:i:s',$mktime);
    }
}

/**
 *  返回格式化(Y-m-d)的日期
 *
 * @param     int    $mktime  时间戳
 * @return    string
 */
if ( ! function_exists('GetDateMk'))
{
    function GetDateMk($mktime)
    {
        if($mktime==&quot;0&quot;) return &quot;暂无&quot;;
        else return MyDate(&quot;Y-m-d&quot;, $mktime);
    }
}


/**
 *  将时间转换为距离现在的精确时间
 *
 * @param     int   $seconds  秒数
 * @return    string
 */
if ( ! function_exists('FloorTime'))
{
    function FloorTime($seconds)
    {
        $times = '';
        $days = floor(($seconds/86400)%30);
        $hours = floor(($seconds/3600)%24);
        $minutes = floor(($seconds/60)%60);
        $seconds = floor($seconds%60);
        if($seconds &gt;= 1) $times .= $seconds.'秒';
        if($minutes &gt;= 1) $times = $minutes.'分钟 '.$times;
        if($hours &gt;= 1) $times = $hours.'小时 '.$times;
        if($days &gt;= 1)  $times = $days.'天';
        if($days &gt; 30) return false;
        $times .= '前';
        return str_replace(&quot; &quot;, '', $times);
    }
}

?&gt;
</pre>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>PHP时间格式函数</title>
		<link>https://www.mudbest.com/%e6%97%b6%e9%97%b4%e6%a0%bc%e5%bc%8f%e5%87%bd%e6%95%b0/</link>
		
		<dc:creator><![CDATA[admin]]></dc:creator>
		<pubDate>Fri, 25 Mar 2011 03:15:15 +0000</pubDate>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[时间戳]]></category>
		<category><![CDATA[时间格式]]></category>
		<guid isPermaLink="false">http://www.mudbest.com/?p=513</guid>

					<description><![CDATA[/** * 时间格式函数 * by hkshadow * Enter description here ... ... <a title="PHP时间格式函数" class="read-more" href="https://www.mudbest.com/%e6%97%b6%e9%97%b4%e6%a0%bc%e5%bc%8f%e5%87%bd%e6%95%b0/" aria-label="阅读 PHP时间格式函数">阅读更多</a>]]></description>
										<content:encoded><![CDATA[<pre class="brush: php; title: ; notranslate">
/**
 * 时间格式函数
 * by hkshadow
 * Enter description here ...
 * @param  $type 1 年月日   2 年月日小时分钟秒        3 年月
 * @param  $val  mktime()
 */
function MkTimeToDate($type,$val){
	if ($type == '1'){
		$dtime = date(&quot;Y-m-d&quot;,$val);
	}else if ($type == '2'){
		$dtime = date(&quot;Y-m-d H:i:s&quot;,$val);
	}else if ($type == '3'){
		$dtime = date(&quot;Y-m&quot;,$val);
	}
	return $dtime;
}
</pre>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
