Свойство | Type | Description | |
---|---|---|---|
$booleanFormat | the text to be displayed when formatting a boolean value. The first element corresponds to the text displayed for false, the second element for true. Defaults to ['No', 'Yes'], where Yes and No will be translated according to [[locale]]. | ||
$calendar | the calendar to be used for date formatting. The value of this property will be directly passed to the constructor of the IntlDateFormatter class. Defaults to null, which means the Gregorian calendar will be used. You may also explicitly pass the constant \IntlDateFormatter::GREGORIAN for Gregorian calendar. To use an alternative calendar like for example the Jalali calendar, set this property to \IntlDateFormatter::TRADITIONAL. The calendar must then be specified in the [[locale]], for example for the persian calendar the configuration for the formatter would be: php 'formatter' => [ 'locale' => 'fa_IR@calendar=persian', 'calendar' => \IntlDateFormatter::TRADITIONAL, ], Available calendar names can be found in the ICU manual. Since PHP 5.5 you may also use an instance of the [[\IntlCalendar]] class. Check the PHP manual for more details. If the PHP intl extension is not available, setting this property will have no effect. | ||
$currencyCode | the 3-letter ISO 4217 currency code indicating the default currency to use for [[asCurrency]]. If not set, the currency code corresponding to [[locale]] will be used. Note that in this case the [[locale]] has to be specified with a country code, e.g. en-US otherwise it is not possible to determine the default currency. | ||
$dateFormat | the default format string to be used to format a [[asDate()|date]]. This can be "short", "medium", "long", or "full", which represents a preset format of different lengths. It can also be a custom format as specified in the ICU manual. Alternatively this can be a string prefixed with php: representing a format that can be recognized by the PHP date()-function. For example: php 'MM/dd/yyyy' // date in ICU format 'php:m/d/Y' // the same date in PHP format | ||
$datetimeFormat | the default format string to be used to format a [[asDatetime()|date and time]]. This can be "short", "medium", "long", or "full", which represents a preset format of different lengths. It can also be a custom format as specified in the ICU manual. Alternatively this can be a string prefixed with php: representing a format that can be recognized by the PHP date()-function. For example: php 'MM/dd/yyyy HH:mm:ss' // date and time in ICU format 'php:m/d/Y H:i:s' // the same date and time in PHP format | ||
$decimalSeparator | the character displayed as the decimal point when formatting a number. If not set, the decimal separator corresponding to [[locale]] will be used. If PHP intl extension is not available, the default value is '.'. | ||
$defaultTimeZone | the time zone that is assumed for input values if they do not include a time zone explicitly. The value must be a valid time zone identifier, e.g. UTC, Europe/Berlin or America/Chicago. Please refer to the php manual for available time zones. It defaults to UTC so you only have to adjust this value if you store datetime values in another time zone in your database. | ||
$locale | the locale ID that is used to localize the date and number formatting. For number and date formatting this is only effective when the PHP intl extension is installed. If not set, [[\yii\base\Application::language]] will be used. | ||
$nullDisplay | the text to be displayed when formatting a null value. Defaults to '(not set)', where (not set) will be translated according to [[locale]]. | ||
$numberFormatterOptions | a list of name value pairs that are passed to the intl Numberformatter::setAttribute() method of all the number formatter objects created by Formatter::createNumberFormatter. This property takes only effect if the PHP intl extension is installed. Please refer to the PHP manual for the possible options. For example to adjust the maximum and minimum value of fraction digits you can configure this property like the following: php [ NumberFormatter::MIN_FRACTION_DIGITS => 0, NumberFormatter::MAX_FRACTION_DIGITS => 2, ] | ||
$numberFormatterSymbols | a list of name value pairs that are passed to the intl Numberformatter::setSymbol() method of all the number formatter objects created by Formatter::createNumberFormatter. This property takes only effect if the PHP intl extension is installed. Please refer to the PHP manual for the possible options. For example to choose a custom currency symbol, e.g. U+20BD instead of руб. for Russian Ruble: php [ NumberFormatter::CURRENCY_SYMBOL => '₽', ] | ||
$numberFormatterTextOptions | a list of name value pairs that are passed to the intl Numberformatter::setTextAttribute() method of all the number formatter objects created by Formatter::createNumberFormatter. This property takes only effect if the PHP intl extension is installed. Please refer to the PHP manual for the possible options. For example to change the minus sign for negative numbers you can configure this property like the following: php [ NumberFormatter::NEGATIVE_PREFIX => 'MINUS', ] | ||
$sizeFormatBase | the base at which a kilobyte is calculated (1000 or 1024 bytes per kilobyte), used by [[asSize]] and [[asShortSize]]. Defaults to 1024. | ||
$thousandSeparator | the character displayed as the thousands separator (also called grouping separator) character when formatting a number. If not set, the thousand separator corresponding to [[locale]] will be used. If PHP intl extension is not available, the default value is ','. | ||
$timeFormat | the default format string to be used to format a [[asTime()|time]]. This can be "short", "medium", "long", or "full", which represents a preset format of different lengths. It can also be a custom format as specified in the ICU manual. Alternatively this can be a string prefixed with php: representing a format that can be recognized by the PHP date()-function. For example: php 'HH:mm:ss' // time in ICU format 'php:H:i:s' // the same time in PHP format | ||
$timeZone | the time zone to use for formatting time and date values. This can be any value that may be passed to date_default_timezone_set() e.g. UTC, Europe/Berlin or America/Chicago. Refer to the php manual for available time zones. If this property is not set, [[\yii\base\Application::timeZone]] will be used. Note that the default time zone for input data is assumed to be UTC by default if no time zone is included in the input date value. If you store your data in a different time zone in the database, you have to adjust [[defaultTimeZone]] accordingly. |
Méthode | Description | |
---|---|---|
asBoolean ( mixed $value ) : string | Formats the value as a boolean. | |
asCurrency ( mixed $value, string $currency = null, array $options = [], array $textOptions = [] ) : string | Formats the value as a currency number. | |
asDate ( integer | string | DateTim\DateTime $value, string $format = null ) : string | Formats the value as a date. | |
asDatetime ( integer | string | DateTim\DateTime $value, string $format = null ) : string | Formats the value as a datetime. | |
asDecimal ( mixed $value, integer $decimals = null, array $options = [], array $textOptions = [] ) : string | Formats the value as a decimal number. | |
asDuration ( DateInterva\DateInterval | string | integer $value, string $implodeString = ', ', string $negativeSign = '-' ) : string | Represents the value as duration in human readable format. | |
asEmail ( string $value, array $options = [] ) : string | Formats the value as a mailto link. | |
asHtml ( string $value, array | null $config = null ) : string | Formats the value as HTML text. | |
asImage ( mixed $value, array $options = [] ) : string | Formats the value as an image tag. | |
asInteger ( mixed $value, array $options = [], array $textOptions = [] ) : string | Formats the value as an integer number by removing any decimal digits without rounding. | |
asNtext ( string $value ) : string | Formats the value as an HTML-encoded plain text with newlines converted into breaks. | |
asOrdinal ( mixed $value ) : string | Formats the value as a ordinal value of a number. | |
asParagraphs ( string $value ) : string | Formats the value as HTML-encoded text paragraphs. | |
asPercent ( mixed $value, integer $decimals = null, array $options = [], array $textOptions = [] ) : string | Formats the value as a percent number with "%" sign. | |
asRaw ( mixed $value ) : string | Formats the value as is without any formatting. | |
asRelativeTime ( integer | string | DateTim\DateTime | DateInterva\DateInterval $value, integer | string | DateTim\DateTime $referenceTime = null ) : string | Formats the value as the time interval between a date and now in human readable form. | |
asScientific ( mixed $value, integer $decimals = null, array $options = [], array $textOptions = [] ) : string | Formats the value as a scientific number. | |
asShortSize ( string | integer | float $value, integer $decimals = null, array $options = [], array $textOptions = [] ) : string | Formats the value in bytes as a size in human readable form for example 12 KB. | |
asSize ( string | integer | float $value, integer $decimals = null, array $options = [], array $textOptions = [] ) : string | Formats the value in bytes as a size in human readable form, for example 12 kilobytes. | |
asSpellout ( mixed $value ) : string | Formats the value as a number spellout. | |
asText ( string $value ) : string | Formats the value as an HTML-encoded plain text. | |
asTime ( integer | string | DateTim\DateTime $value, string $format = null ) : string | Formats the value as a time. | |
asTimestamp ( integer | string | DateTim\DateTime $value ) : string | Formats a date, time or datetime in a float number as UNIX timestamp (seconds since 01-01-1970). | |
asUrl ( mixed $value, array $options = [] ) : string | Formats the value as a hyperlink. | |
format ( mixed $value, string | array $format ) : string | Formats the value based on the given format type. | |
init ( ) |
Méthode | Description | |
---|---|---|
createNumberFormatter ( integer $style, integer $decimals = null, array $options = [], array $textOptions = [] ) : NumberFormatter | Creates a number formatter based on the given type and format. | |
normalizeDatetimeValue ( integer | string | DateTim\DateTime $value, boolean $checkTimeInfo = false ) : DateTim\DateTime | array | Normalizes the given datetime value as a DateTime object that can be taken by various date/time formatting methods. | |
normalizeNumericValue ( mixed $value ) : float | integer | Normalizes a numeric input value |
Méthode | Description | |
---|---|---|
formatDateTimeValue ( integer | string | DateTim\DateTime $value, string $format, string $type ) : string | ||
formatSizeNumber ( string | integer | float $value, integer $decimals, array $options, array $textOptions ) : array | Given the value in bytes formats number part of the human readable form. |
public asCurrency ( mixed $value, string $currency = null, array $options = [], array $textOptions = [] ) : string | ||
$value | mixed | the value to be formatted. |
$currency | string | the 3-letter ISO 4217 currency code indicating the currency to use. If null, [[currencyCode]] will be used. |
$options | array | optional configuration for the number formatter. This parameter will be merged with [[numberFormatterOptions]]. |
$textOptions | array | optional configuration for the number formatter. This parameter will be merged with [[numberFormatterTextOptions]]. |
Résultat | string | the formatted result. |
public asDate ( integer | string | DateTim\DateTime $value, string $format = null ) : string | ||
$value | integer | string | DateTim\DateTime | the value to be formatted. The following types of value are supported: - an integer representing a UNIX timestamp - a string that can be [parsed to create a DateTime object](http://php.net/manual/en/datetime.formats.php). The timestamp is assumed to be in [[defaultTimeZone]] unless a time zone is explicitly given. - a PHP [DateTime](http://php.net/manual/en/class.datetime.php) object |
$format | string | the format used to convert the value into a date string. If null, [[dateFormat]] will be used. This can be "short", "medium", "long", or "full", which represents a preset format of different lengths. It can also be a custom format as specified in the [ICU manual](http://userguide.icu-project.org/formatparse/datetime). Alternatively this can be a string prefixed with `php:` representing a format that can be recognized by the PHP [date()](http://php.net/manual/en/function.date.php)-function. |
Résultat | string | the formatted result. |
public asDatetime ( integer | string | DateTim\DateTime $value, string $format = null ) : string | ||
$value | integer | string | DateTim\DateTime | the value to be formatted. The following types of value are supported: - an integer representing a UNIX timestamp - a string that can be [parsed to create a DateTime object](http://php.net/manual/en/datetime.formats.php). The timestamp is assumed to be in [[defaultTimeZone]] unless a time zone is explicitly given. - a PHP [DateTime](http://php.net/manual/en/class.datetime.php) object |
$format | string | the format used to convert the value into a date string. If null, [[dateFormat]] will be used. This can be "short", "medium", "long", or "full", which represents a preset format of different lengths. It can also be a custom format as specified in the [ICU manual](http://userguide.icu-project.org/formatparse/datetime). Alternatively this can be a string prefixed with `php:` representing a format that can be recognized by the PHP [date()](http://php.net/manual/en/function.date.php)-function. |
Résultat | string | the formatted result. |
public asDecimal ( mixed $value, integer $decimals = null, array $options = [], array $textOptions = [] ) : string | ||
$value | mixed | the value to be formatted. |
$decimals | integer | the number of digits after the decimal point. If not given the number of digits is determined from the [[locale]] and if the [PHP intl extension](http://php.net/manual/en/book.intl.php) is not available defaults to `2`. |
$options | array | optional configuration for the number formatter. This parameter will be merged with [[numberFormatterOptions]]. |
$textOptions | array | optional configuration for the number formatter. This parameter will be merged with [[numberFormatterTextOptions]]. |
Résultat | string | the formatted result. |
public asDuration ( DateInterva\DateInterval | string | integer $value, string $implodeString = ', ', string $negativeSign = '-' ) : string | ||
$value | DateInterva\DateInterval | string | integer | the value to be formatted. Acceptable formats: - [DateInterval object](http://php.net/manual/ru/class.dateinterval.php) - integer - number of seconds. For example: value `131` represents `2 minutes, 11 seconds` - ISO8601 duration format. For example, all of these values represent `1 day, 2 hours, 30 minutes` duration: `2015-01-01T13:00:00Z/2015-01-02T13:30:00Z` - between two datetime values `2015-01-01T13:00:00Z/P1D2H30M` - time interval after datetime value `P1D2H30M/2015-01-02T13:30:00Z` - time interval before datetime value `P1D2H30M` - simply a date interval `P-1D2H30M` - a negative date interval (`-1 day, 2 hours, 30 minutes`) |
$implodeString | string | will be used to concatenate duration parts. Defaults to `, `. |
$negativeSign | string | will be prefixed to the formatted duration, when it is negative. Defaults to `-`. |
Résultat | string | the formatted duration. |
public asInteger ( mixed $value, array $options = [], array $textOptions = [] ) : string | ||
$value | mixed | the value to be formatted. |
$options | array | optional configuration for the number formatter. This parameter will be merged with [[numberFormatterOptions]]. |
$textOptions | array | optional configuration for the number formatter. This parameter will be merged with [[numberFormatterTextOptions]]. |
Résultat | string | the formatted result. |
tag. One or multiple consecutive empty lines divide two paragraphs.
public asParagraphs ( string $value ) : string | ||
$value | string | the value to be formatted. |
Résultat | string | the formatted result. |
public asPercent ( mixed $value, integer $decimals = null, array $options = [], array $textOptions = [] ) : string | ||
$value | mixed | the value to be formatted. It must be a factor e.g. `0.75` will result in `75%`. |
$decimals | integer | the number of digits after the decimal point. |
$options | array | optional configuration for the number formatter. This parameter will be merged with [[numberFormatterOptions]]. |
$textOptions | array | optional configuration for the number formatter. This parameter will be merged with [[numberFormatterTextOptions]]. |
Résultat | string | the formatted result. |
public asRelativeTime ( integer | string | DateTim\DateTime | DateInterva\DateInterval $value, integer | string | DateTim\DateTime $referenceTime = null ) : string | ||
$value | integer | string | DateTim\DateTime | DateInterva\DateInterval | the value to be formatted. The following types of value are supported: - an integer representing a UNIX timestamp - a string that can be [parsed to create a DateTime object](http://php.net/manual/en/datetime.formats.php). The timestamp is assumed to be in [[defaultTimeZone]] unless a time zone is explicitly given. - a PHP [DateTime](http://php.net/manual/en/class.datetime.php) object - a PHP DateInterval object (a positive time interval will refer to the past, a negative one to the future) |
$referenceTime | integer | string | DateTim\DateTime | if specified the value is used as a reference time instead of `now` when `$value` is not a `DateInterval` object. |
Résultat | string | the formatted result. |
public asScientific ( mixed $value, integer $decimals = null, array $options = [], array $textOptions = [] ) : string | ||
$value | mixed | the value to be formatted. |
$decimals | integer | the number of digits after the decimal point. |
$options | array | optional configuration for the number formatter. This parameter will be merged with [[numberFormatterOptions]]. |
$textOptions | array | optional configuration for the number formatter. This parameter will be merged with [[numberFormatterTextOptions]]. |
Résultat | string | the formatted result. |
public asShortSize ( string | integer | float $value, integer $decimals = null, array $options = [], array $textOptions = [] ) : string | ||
$value | string | integer | float | value in bytes to be formatted. |
$decimals | integer | the number of digits after the decimal point. |
$options | array | optional configuration for the number formatter. This parameter will be merged with [[numberFormatterOptions]]. |
$textOptions | array | optional configuration for the number formatter. This parameter will be merged with [[numberFormatterTextOptions]]. |
Résultat | string | the formatted result. |
public asSize ( string | integer | float $value, integer $decimals = null, array $options = [], array $textOptions = [] ) : string | ||
$value | string | integer | float | value in bytes to be formatted. |
$decimals | integer | the number of digits after the decimal point. |
$options | array | optional configuration for the number formatter. This parameter will be merged with [[numberFormatterOptions]]. |
$textOptions | array | optional configuration for the number formatter. This parameter will be merged with [[numberFormatterTextOptions]]. |
Résultat | string | the formatted result. |
public asSpellout ( mixed $value ) : string | ||
$value | mixed | the value to be formatted |
Résultat | string | the formatted result. |
public asTime ( integer | string | DateTim\DateTime $value, string $format = null ) : string | ||
$value | integer | string | DateTim\DateTime | the value to be formatted. The following types of value are supported: - an integer representing a UNIX timestamp - a string that can be [parsed to create a DateTime object](http://php.net/manual/en/datetime.formats.php). The timestamp is assumed to be in [[defaultTimeZone]] unless a time zone is explicitly given. - a PHP [DateTime](http://php.net/manual/en/class.datetime.php) object |
$format | string | the format used to convert the value into a date string. If null, [[timeFormat]] will be used. This can be "short", "medium", "long", or "full", which represents a preset format of different lengths. It can also be a custom format as specified in the [ICU manual](http://userguide.icu-project.org/formatparse/datetime). Alternatively this can be a string prefixed with `php:` representing a format that can be recognized by the PHP [date()](http://php.net/manual/en/function.date.php)-function. |
Résultat | string | the formatted result. |
public asTimestamp ( integer | string | DateTim\DateTime $value ) : string | ||
$value | integer | string | DateTim\DateTime | the value to be formatted. The following types of value are supported: - an integer representing a UNIX timestamp - a string that can be [parsed to create a DateTime object](http://php.net/manual/en/datetime.formats.php). The timestamp is assumed to be in [[defaultTimeZone]] unless a time zone is explicitly given. - a PHP [DateTime](http://php.net/manual/en/class.datetime.php) object |
Résultat | string | the formatted result. |
protected createNumberFormatter ( integer $style, integer $decimals = null, array $options = [], array $textOptions = [] ) : NumberFormatter | ||
$style | integer | the type of the number formatter. Values: NumberFormatter::DECIMAL, ::CURRENCY, ::PERCENT, ::SCIENTIFIC, ::SPELLOUT, ::ORDINAL ::DURATION, ::PATTERN_RULEBASED, ::DEFAULT_STYLE, ::IGNORE |
$decimals | integer | the number of digits after the decimal point. |
$options | array | optional configuration for the number formatter. This parameter will be merged with [[numberFormatterOptions]]. |
$textOptions | array | optional configuration for the number formatter. This parameter will be merged with [[numberFormatterTextOptions]]. |
Résultat | NumberFormatter | the created formatter instance |
public format ( mixed $value, string | array $format ) : string | ||
$value | mixed | the value to be formatted. |
$format | string | array | the format of the value, e.g., "html", "text". To specify additional parameters of the formatting method, you may use an array. The first element of the array specifies the format name, while the rest of the elements will be used as the parameters to the formatting method. For example, a format of `['date', 'Y-m-d']` will cause the invocation of `asDate($value, 'Y-m-d')`. |
Résultat | string | the formatting result. |
protected normalizeDatetimeValue ( integer | string | DateTim\DateTime $value, boolean $checkTimeInfo = false ) : DateTim\DateTime | array | ||
$value | integer | string | DateTim\DateTime | the datetime value to be normalized. The following types of value are supported: - an integer representing a UNIX timestamp - a string that can be [parsed to create a DateTime object](http://php.net/manual/en/datetime.formats.php). The timestamp is assumed to be in [[defaultTimeZone]] unless a time zone is explicitly given. - a PHP [DateTime](http://php.net/manual/en/class.datetime.php) object |
$checkTimeInfo | boolean | whether to also check if the date/time value has some time information attached. Defaults to `false`. If `true`, the method will then return an array with the first element being the normalized timestamp and the second a boolean indicating whether the timestamp has time information or it is just a date value. This parameter is available since version 2.0.1. |
Résultat | DateTim\DateTime | array | the normalized datetime value. Since version 2.0.1 this may also return an array if `$checkTimeInfo` is true. The first element of the array is the normalized timestamp and the second is a boolean indicating whether the timestamp has time information or it is just a date value. |
public $booleanFormat |
public $calendar |
public $currencyCode |
public $dateFormat |
public $datetimeFormat |
public $decimalSeparator |
public $defaultTimeZone |
public $locale |
public $nullDisplay |
public $numberFormatterOptions |
public $numberFormatterSymbols |
public $numberFormatterTextOptions |
public $sizeFormatBase |
public $thousandSeparator |
public $timeFormat |
public $timeZone |