framework/i18n/CDateFormatter.php
public function format($pattern,$time)
	{
		if($time===null)
			return null;

		if(is_string($time))
		{
			if(ctype_digit($time) || ($time{0}=='-' && ctype_digit(substr($time, 1))))
				$time=(int)$time;
			else
				$time=strtotime($time);
		}
		$date=CTimestamp::getDate($time,false,false);
		$tokens=$this->parseFormat($pattern);
		foreach($tokens as &$token)
		{
			if(is_array($token)) // a callback: method name, sub-pattern
				$token=$this->{$token[0]}($token[1],$date);
		}
		return implode('',$tokens);
	}
public function format($pattern,$time)
	{
		if($time===null)
			return null;

		if(is_string($time))
		{
			if(ctype_digit($time) || ($time{0}=='-' && ctype_digit(substr($time, 1))))
				$time=(int)$time;
			else
				$time=strtotime($time);
		}
		$date=CTimestamp::getDate($time,false,false);
		$tokens=$this->parseFormat($pattern);
		foreach($tokens as &$token)
		{
			if(is_array($token)) // a callback: method name, sub-pattern
				$token=$this->{$token[0]}($token[1],$date);
		}
		return implode('',$tokens);
	}
public function format ( $ pattern , $ time ) { if ( $ time === null ) return null ; if ( is_string ( $ time ) ) { if ( ctype_digit ( $ time ) || ( $ time { 0 } == '-' && ctype_digit ( substr ( $ time , 1 ) ) ) ) $ time = ( int ) $ time ; else $ time = strtotime ( $ time ) ; } $ date = CTimestamp :: getDate ( $ time , false , false ) ; $ tokens = $ this -> parseFormat ( $ pattern ) ; foreach ( $ tokens as & $ token ) { if ( is_array ( $ token ) ) // a callback: method name, sub-pattern $ token = $ this -> { $ token [ 0 ] } ( $ token [ 1 ] , $ date ) ; } return implode ( '' , $ tokens ) ; }
Formats a date according to a customized pattern.
@param string $pattern the pattern (See {@link http://www.unicode.org/reports/tr35/tr35-dates.html#Date_Format_Patterns})
@param mixed $time UNIX timestamp or a string in strtotime format
@return string formatted date time. Null if $time is null. (the null value check is available since Yii 1.1.11)
Formats a date according to a customized pattern .