src/classes/CCDate.php
public static function relative($ts)
	{
		if(!ctype_digit($ts))
			$ts = strtotime($ts);
	
		$diff = time() - $ts;
		if($diff == 0)
			return __('Core::common.date.now');
		elseif($diff > 0)
		{
			$day_diff = floor($diff / 86400);
			if($day_diff == 0)
			{
				if($diff < 60) return __('Core::common.date.just_now');
				if($diff < 120) return __('Core::common.date.minute_ago');
				if($diff < 3600) return __('Core::common.date.minutes_ago', array( 'num' => floor($diff / 60) ) );
				if($diff < 7200) return __('Core::common.date.hour_ago');
				if($diff < 86400) return __('Core::common.date.hours_ago', array( 'num' => floor($diff / 3600) ) );
			}
			if($day_diff == 1) return __('Core::common.date.yesterday');
			if($day_diff < 7) return __('Core::common.date.days_ago', array( 'num' => $day_diff ) );
			if($day_diff < 31) return __('Core::common.date.weeks_ago', array( 'num' => ceil($day_diff / 7) ) );
			if($day_diff < 60) return __('Core::common.date.last_month');
			return date('F Y', $ts);
		}
		else
		{
			$diff = abs($diff);
			$day_diff = floor($diff / 86400);
			if($day_diff == 0)
			{
				if($diff < 120) return __('Core::common.date.in_minute');
				if($diff < 3600) return __('Core::common.date.in_minutes', array( 'num' => floor($diff / 60) ) );
				if($diff < 7200) return  __('Core::common.date.in_hour');
				if($diff < 86400) return __('Core::common.date.in_hours', array( 'num' => floor($diff / 3600) ) );
			}
			if($day_diff == 1) return __('Core::common.date.tomorrow');
			if($day_diff < 4) return date('l', $ts);
			if($day_diff < 7 + (7 - date('w'))) return 'next week';
			if(ceil($day_diff / 7) < 4) return 'in ' . ceil($day_diff / 7) . ' weeks';
			if(date('n', $ts) == date('n') + 1) return 'next month';
			return date('F Y', $ts);
		}
	}
public static function relative($ts)
	{
		if(!ctype_digit($ts))
			$ts = strtotime($ts);
	
		$diff = time() - $ts;
		if($diff == 0)
			return __('Core::common.date.now');
		elseif($diff > 0)
		{
			$day_diff = floor($diff / 86400);
			if($day_diff == 0)
			{
				if($diff < 60) return __('Core::common.date.just_now');
				if($diff < 120) return __('Core::common.date.minute_ago');
				if($diff < 3600) return __('Core::common.date.minutes_ago', array( 'num' => floor($diff / 60) ) );
				if($diff < 7200) return __('Core::common.date.hour_ago');
				if($diff < 86400) return __('Core::common.date.hours_ago', array( 'num' => floor($diff / 3600) ) );
			}
			if($day_diff == 1) return __('Core::common.date.yesterday');
			if($day_diff < 7) return __('Core::common.date.days_ago', array( 'num' => $day_diff ) );
			if($day_diff < 31) return __('Core::common.date.weeks_ago', array( 'num' => ceil($day_diff / 7) ) );
			if($day_diff < 60) return __('Core::common.date.last_month');
			return date('F Y', $ts);
		}
		else
		{
			$diff = abs($diff);
			$day_diff = floor($diff / 86400);
			if($day_diff == 0)
			{
				if($diff < 120) return __('Core::common.date.in_minute');
				if($diff < 3600) return __('Core::common.date.in_minutes', array( 'num' => floor($diff / 60) ) );
				if($diff < 7200) return  __('Core::common.date.in_hour');
				if($diff < 86400) return __('Core::common.date.in_hours', array( 'num' => floor($diff / 3600) ) );
			}
			if($day_diff == 1) return __('Core::common.date.tomorrow');
			if($day_diff < 4) return date('l', $ts);
			if($day_diff < 7 + (7 - date('w'))) return 'next week';
			if(ceil($day_diff / 7) < 4) return 'in ' . ceil($day_diff / 7) . ' weeks';
			if(date('n', $ts) == date('n') + 1) return 'next month';
			return date('F Y', $ts);
		}
	}
public static function relative ( $ ts ) { if ( ! ctype_digit ( $ ts ) ) $ ts = strtotime ( $ ts ) ; $ diff = time ( ) - $ ts ; if ( $ diff == 0 ) return __ ( 'Core::common.date.now' ) ; elseif ( $ diff > 0 ) { $ day_diff = floor ( $ diff / 86400 ) ; if ( $ day_diff == 0 ) { if ( $ diff < 60 ) return __ ( 'Core::common.date.just_now' ) ; if ( $ diff < 120 ) return __ ( 'Core::common.date.minute_ago' ) ; if ( $ diff < 3600 ) return __ ( 'Core::common.date.minutes_ago' , array ( 'num' => floor ( $ diff / 60 ) ) ) ; if ( $ diff < 7200 ) return __ ( 'Core::common.date.hour_ago' ) ; if ( $ diff < 86400 ) return __ ( 'Core::common.date.hours_ago' , array ( 'num' => floor ( $ diff / 3600 ) ) ) ; } if ( $ day_diff == 1 ) return __ ( 'Core::common.date.yesterday' ) ; if ( $ day_diff < 7 ) return __ ( 'Core::common.date.days_ago' , array ( 'num' => $ day_diff ) ) ; if ( $ day_diff < 31 ) return __ ( 'Core::common.date.weeks_ago' , array ( 'num' => ceil ( $ day_diff / 7 ) ) ) ; if ( $ day_diff < 60 ) return __ ( 'Core::common.date.last_month' ) ; return date ( 'F Y' , $ ts ) ; } else { $ diff = abs ( $ diff ) ; $ day_diff = floor ( $ diff / 86400 ) ; if ( $ day_diff == 0 ) { if ( $ diff < 120 ) return __ ( 'Core::common.date.in_minute' ) ; if ( $ diff < 3600 ) return __ ( 'Core::common.date.in_minutes' , array ( 'num' => floor ( $ diff / 60 ) ) ) ; if ( $ diff < 7200 ) return __ ( 'Core::common.date.in_hour' ) ; if ( $ diff < 86400 ) return __ ( 'Core::common.date.in_hours' , array ( 'num' => floor ( $ diff / 3600 ) ) ) ; } if ( $ day_diff == 1 ) return __ ( 'Core::common.date.tomorrow' ) ; if ( $ day_diff < 4 ) return date ( 'l' , $ ts ) ; if ( $ day_diff < 7 + ( 7 - date ( 'w' ) ) ) return 'next week' ; if ( ceil ( $ day_diff / 7 ) < 4 ) return 'in ' . ceil ( $ day_diff / 7 ) . ' weeks' ; if ( date ( 'n' , $ ts ) == date ( 'n' ) + 1 ) return 'next month' ; return date ( 'F Y' , $ ts ) ; } }
to string relative string

@param int	$ts
@return string
to string relative string