Location: PHPKode > projects > WH Community > wh_community/functions/messagebox.php
<?php

	function relativeTime($dt,$precision=2) {
		$times=array(	365*24*60*60	=> "year",
						30*24*60*60		=> "month",
						7*24*60*60		=> "week",
						24*60*60		=> "day",
						60*60			=> "hour",
						60				=> "minute",
						1				=> "second");
		
		$passed=time()-$dt;
		
		if($passed<5) {
		
        $output='' . $lang['less_five_seconds'] . '';
            
            }else{
            
			$output=array();
			$exit=0;
			
			foreach($times as $period=>$name) {
				if($exit>=$precision || ($exit>0 && $period<60)) break;
				$result = floor($passed/$period);
				
				if($result>0) {
				
					$output[]=$result.' '.$name.($result==1?'':'s');
					$passed-=$result*$period;
					$exit++;
				
				}elseif($exit>0) $exit++;
                }
			
			$output=implode(' and ',$output).'';
            }
        
		return $output;
        }


	function formatTweet($tweet,$dt) {
		if(is_string($dt)) $dt=strtotime($dt);

		include_once('bbcode.php');
		include_once('badwords.php');

		$tweet = parseBBCode2HTML(delBad(nl2br(stripslashes(strip_tags($tweet)))));

		return '<li>
		        <img class="avatar" src="images/avatars/default.png" width="40" height="40" vspace="5" alt="Avatar">
		        <div class="tweetTxt">
		        ' . preg_replace('/((?:http|https|ftp):\/\/(?:[A-Z0-9][A-Z0-9_-]*(?:\.[A-Z0-9][A-Z0-9_-]*)+):?(\d+)?\/?[^\s\"\']+)/i','<a href="$1" rel="nofollow" target="blank">$1</a>',$tweet).'
		        <div class="date">' . relativeTime($dt) . '</div>
		        </div>
		        <div class="clear"></div>
		        </li>';
		        }

?>
Return current item: WH Community