這看起來(lái)更加人性化,好吧,上代碼 復(fù)制代碼 代碼如下: <?php class timeAgo { static $timeagoObject; private $rustle; private $unit;

private function __construct() {

} private function __clone(){ " /> A级韩国乱理伦片在线观看,国产亚洲精品久久孕妇呦呦你懂,三级黄.色

天天躁日日躁狠狠躁AV麻豆-天天躁人人躁人人躁狂躁-天天澡夜夜澡人人澡-天天影视香色欲综合网-国产成人女人在线视频观看-国产成人女人视频在线观看

php中將時(shí)間差轉(zhuǎn)換為字符串提示的實(shí)現(xiàn)代碼

如微博

這看起來(lái)更加人性化,好吧,上代碼
復(fù)制代碼 代碼如下:
<?php
class timeAgo
{
static $timeagoObject;
private $rustle;
private $unit;

private function __construct()
{

}
private function __clone(){ }
public static function getObject()
{
if(! (self::$timeagoObject instanceof self) )
self::$timeagoObject = new timeAgo();

return self::$timeagoObject;
}
private function count_int($unix_C) // main function
{
if(! (isset($unix_C) || is_numeric($unix_C)) )
return 'don/'t find parameter';

$d = time()-$unix_C ; // $d - unix time difference value
$d_int =(int)floor($d/60) ; // minimum unit -- minutes unix/60

$this->unit = 0 ; // is minutes,hour or day?

if($d_int < 60){ // minutes in one hour 3600
$this->rustle = $d_int;
$this->unit = 1;
}
else if($d_int < 720){ //hour in one day 3600*12
$this->rustle = floor($d_int/60);
$this->unit = 2 ;
}
else if($d_int < 7200){ //day in ten days 3600*12*10
$this->rustle = floor($d_int/720);
$this->unit = 3 ;
}
else{
$this->rustle = $d ;
$this->unit = 4 ;
}
}
public function piece_str($C)
{
$this->count_int($C);

$u = '';
switch( $this->unit )
{
case 1:
$u = 'minute';
break;
case 2:
$u = 'hour';
break;
case 3:
$u = 'day';
break;
case 4:
$u = '';
break;
case 0:
return 'sorry , get time is fail';
}
if($this->unit < 4)
{
if($this->rustle > 1)
return (string)$this->rustle.$u.'s ago';
else if($this->rustle == 1)
return (string)$this->rustle.$u.'ago';
else
return 'Just now';
}
}
/* example: $ago = timeAgo::getObject();
* echo $ago->piece_str($unix);
* // 2 days ago
*/
}
?>

php技術(shù)php中將時(shí)間差轉(zhuǎn)換為字符串提示的實(shí)現(xiàn)代碼,轉(zhuǎn)載需保留來(lái)源!

鄭重聲明:本文版權(quán)歸原作者所有,轉(zhuǎn)載文章僅為傳播更多信息之目的,如作者信息標(biāo)記有誤,請(qǐng)第一時(shí)間聯(lián)系我們修改或刪除,多謝。

主站蜘蛛池模板: 动漫美女脱小内内露尿口 | 日日摸夜夜添无码AVA片 | 男人免费网站 | av狼新人开放注册区 | 精品视频中文字幕 | 动漫成年美女黄漫网站 | 黑丝袜论坛 | 干丝袜美女 | 免费人成在线观看网站视频 | 亚洲区 bt下载 | 女子初尝黑人巨嗷嗷叫 | 伊人久久网站 | 99久久久久国产精品免费 | 亚洲最大成人 | 国产日韩欧美另类 | 国产精品亚洲专区在线播放 | 欧美.亚洲.日韩.天堂 | 国产99久久久欧美黑人刘玥 | 国内精品久久人妻无码HD浪潮 | 91女神娇喘| 国产精品一区二区免费 | 亚洲成年人免费网站 | 亚洲黄色在线视频 | 久久超碰国产精品最新 | 白白操在线视频 | 亚洲AV成人无码999WWW | 女的把腿张开男的往里面插 | 免费可以看污动画软件 | 解开美女胸衣2破解版 | 欧美亚洲天堂网 | 天天色天天综合网 | 办公室沙发口爆12P 办公室日本肉丝OL在线 | 97人人超碰国产精品最新蜜芽 | 国产精华av午夜在线观看 | 处破女免费播放 | 囯产愉拍亚洲精品一区 | 黄色三级视频在线观看 | 婷婷激情综合色五月久久竹菊影视 | 亚洲欧美人成视频在线 | 女人把腿张开叫男人桶免费视频 | 久久久久青草大香线综合精品 |