时时商务社区

标题: php将时间差转换为字符串提示 [打印本页]

作者: 阿情    时间: 2018-2-14 08:32

            这看起来更加人性化,好吧,上代码
[U]复制代码[/U] 代码如下:
unit = 0 ; // is minutes,hour or day?
if($d_int rustle = $d_int;
$this->unit = 1;
}
else if($d_int rustle = floor($d_int/60);
$this->unit = 2 ;
}
else if($d_int 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 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 8小时时间差的解决方法小结
  • php中计算时间差的几种方法
  • 在php和MySql中计算时间差的方法
  • php中将时间差转换为字符串提示的实现代码
  • PHP输出时间差函数代码
  • php计算两个日期时间差(返回年、月、日)
  • php计算两个日期相差天数的方法
  • 在php和MySql中计算时间差的方法详解
  • php判断两个日期之间相差多少个月份的方法
  • php获取给定日期相差天数的方法分析
  • PHP简单计算两个时间差的方法示例
            




    欢迎光临 时时商务社区 (http://bbs.4435.cn/) Powered by Discuz! X3.2