您好,欢迎访问一九零五行业门户网

字符串常量 php中将时间差转换为字符串提示的实现代码

如微博
这看起来更加人性化,好吧,上代码
复制代码 代码如下:
unit = 0 ; // is minutes,hour or day?
if($d_int $this->rustle = $d_int;
$this->unit = 1;
}
else if($d_int $this->rustle = floor($d_int/60);
$this->unit = 2 ;
}
else if($d_int $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 {
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中将时间差转换为字符串提示的实现代码,包括了字符串常量方面的内容,希望对php教程有兴趣的朋友有所帮助。
其它类似信息

推荐信息