小编Dar*_*rix的帖子

删除特定字符串后的所有内容(文本的其余部分)

如何在像“gnirts”这样的字符串之后删除所有内容。这可能会让你更好地理解: 之前

之后

notepad++

5
推荐指数
1
解决办法
2万
查看次数

在PHP中将时间戳转换为时间

我有这个时间戳PHP代码,它没有显示正确的时间.它总是显示8小时前,当时间假设是几分钟前.

  /**
  * Convert a timestap into timeago format
  * @param time
  * @return timeago
  */  

    public static function timeago($time, $tense = "ago"){
      if(empty($time)) return "n/a";
       $time=strtotime($time);
       $periods = array("second", "minute", "hour", "day", "week", "month", "year", "decade");
       $lengths = array("60","60","24","7","4.35","12","10");
       $now = time();
         $difference = $now - $time;
         for($j = 0; $difference >= $lengths[$j] && $j < count($lengths)-1; $j++) {
           $difference /= $lengths[$j];
         }
         $difference = round($difference);
         if($difference != 1) {
           $periods[$j].= "s";
         }
       return "$difference $periods[$j] $tense ";
    } …
Run Code Online (Sandbox Code Playgroud)

php timestamp

0
推荐指数
1
解决办法
2766
查看次数

标签 统计

notepad++ ×1

php ×1

timestamp ×1