PHP 클래스 yii\i18n\Formatter

The formatting methods provided by Formatter are all named in the form of asXyz(). The behavior of some of them may be configured via the properties of Formatter. For example, by configuring [[dateFormat]], one may control how Formatter::asDate formats the value into a date string. Formatter is configured as an application component in Application by default. You can access that instance via Yii::$app->formatter. The Formatter class is designed to format values according to a [[locale]]. For this feature to work the PHP intl extension has to be installed. Most of the methods however work also if the PHP intl extension is not installed by providing a fallback implementation. Without intl month and day names are in English only.
부터: 2.0
저자: Qiang Xue ([email protected])
저자: Enrica Ruedin ([email protected])
저자: Carsten Brandt ([email protected])
상속: extends yii\base\Component
파일 보기 프로젝트 열기: yiisoft/yii2 1 사용 예제들

공개 프로퍼티들

프로퍼티 타입 설명
$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.

공개 메소드들

메소드 설명
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 ( )

보호된 메소드들

메소드 설명
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

비공개 메소드들

메소드 설명
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.

메소드 상세

asBoolean() 공개 메소드

Formats the value as a boolean.
또한 보기: booleanFormat
public asBoolean ( mixed $value ) : string
$value mixed the value to be formatted.
리턴 string the formatted result.

asCurrency() 공개 메소드

This function does not require the PHP intl extension to be installed to work, but it is highly recommended to install it to get good formatting results.
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]].
리턴 string the formatted result.

asDate() 공개 메소드

Formats the value as a date.
또한 보기: dateFormat
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.
리턴 string the formatted result.

asDatetime() 공개 메소드

Formats the value as a datetime.
또한 보기: datetimeFormat
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.
리턴 string the formatted result.

asDecimal() 공개 메소드

Property [[decimalSeparator]] will be used to represent the decimal point. The value is rounded automatically to the defined decimal digits.
또한 보기: decimalSeparator
또한 보기: thousandSeparator
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]].
리턴 string the formatted result.

asDuration() 공개 메소드

Represents the value as duration in human readable format.
부터: 2.0.7
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 `-`.
리턴 string the formatted duration.

asEmail() 공개 메소드

Formats the value as a mailto link.
public asEmail ( string $value, array $options = [] ) : string
$value string the value to be formatted.
$options array the tag options in terms of name-value pairs. See [[Html::mailto()]].
리턴 string the formatted result.

asHtml() 공개 메소드

The value will be purified using [[HtmlPurifier]] to avoid XSS attacks. Use Formatter::asRaw if you do not want any purification of the value.
public asHtml ( string $value, array | null $config = null ) : string
$value string the value to be formatted.
$config array | null the configuration for the HTMLPurifier class.
리턴 string the formatted result.

asImage() 공개 메소드

Formats the value as an image tag.
public asImage ( mixed $value, array $options = [] ) : string
$value mixed the value to be formatted.
$options array the tag options in terms of name-value pairs. See [[Html::img()]].
리턴 string the formatted result.

asInteger() 공개 메소드

Formats the value as an integer number by removing any decimal digits without rounding.
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]].
리턴 string the formatted result.

asNtext() 공개 메소드

Formats the value as an HTML-encoded plain text with newlines converted into breaks.
public asNtext ( string $value ) : string
$value string the value to be formatted.
리턴 string the formatted result.

asOrdinal() 공개 메소드

This function requires the PHP intl extension to be installed.
public asOrdinal ( mixed $value ) : string
$value mixed the value to be formatted
리턴 string the formatted result.

asParagraphs() 공개 메소드

Each text paragraph is enclosed within a

tag. One or multiple consecutive empty lines divide two paragraphs.

public asParagraphs ( string $value ) : string
$value string the value to be formatted.
리턴 string the formatted result.

asPercent() 공개 메소드

Formats the value as a percent number with "%" sign.
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]].
리턴 string the formatted result.

asRaw() 공개 메소드

This method simply returns back the parameter without any format. The only exception is a null value which will be formatted using [[nullDisplay]].
public asRaw ( mixed $value ) : string
$value mixed the value to be formatted.
리턴 string the formatted result.

asRelativeTime() 공개 메소드

This method can be used in three different ways: 1. Using a timestamp that is relative to now. 2. Using a timestamp that is relative to the $referenceTime. 3. Using a DateInterval object.
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.
리턴 string the formatted result.

asScientific() 공개 메소드

Formats the value as a scientific number.
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]].
리턴 string the formatted result.

asShortSize() 공개 메소드

This is the short form of [[asSize]]. If [[sizeFormatBase]] is 1024, binary prefixes (e.g. kibibyte/KiB, mebibyte/MiB, ...) are used in the formatting result.
또한 보기: sizeFormatBase
또한 보기: asSize
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]].
리턴 string the formatted result.

asSize() 공개 메소드

If [[sizeFormatBase]] is 1024, binary prefixes (e.g. kibibyte/KiB, mebibyte/MiB, ...) are used in the formatting result.
또한 보기: sizeFormatBase
또한 보기: asShortSize
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]].
리턴 string the formatted result.

asSpellout() 공개 메소드

This function requires the PHP intl extension to be installed.
public asSpellout ( mixed $value ) : string
$value mixed the value to be formatted
리턴 string the formatted result.

asText() 공개 메소드

Formats the value as an HTML-encoded plain text.
public asText ( string $value ) : string
$value string the value to be formatted.
리턴 string the formatted result.

asTime() 공개 메소드

Formats the value as a time.
또한 보기: timeFormat
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.
리턴 string the formatted result.

asTimestamp() 공개 메소드

Formats a date, time or datetime in a float number as UNIX timestamp (seconds since 01-01-1970).
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
리턴 string the formatted result.

asUrl() 공개 메소드

Formats the value as a hyperlink.
public asUrl ( mixed $value, array $options = [] ) : string
$value mixed the value to be formatted.
$options array the tag options in terms of name-value pairs. See [[Html::a()]].
리턴 string the formatted result.

createNumberFormatter() 보호된 메소드

You may override this method to create a number formatter based on patterns.
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]].
리턴 NumberFormatter the created formatter instance

format() 공개 메소드

This method will call one of the "as" methods available in this class to do the formatting. For type "xyz", the method "asXyz" will be used. For example, if the format is "html", then Formatter::asHtml will be used. Format names are case insensitive.
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')`.
리턴 string the formatting result.

init() 공개 메소드

public init ( )

normalizeDatetimeValue() 보호된 메소드

Normalizes the given datetime value as a DateTime object that can be taken by various date/time formatting methods.
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.
리턴 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.

normalizeNumericValue() 보호된 메소드

- everything empty will result in 0 - a numeric string will be casted to float - everything else will be returned if it is numeric, otherwise an exception is thrown.
protected normalizeNumericValue ( mixed $value ) : float | integer
$value mixed the input value
리턴 float | integer the normalized number value

프로퍼티 상세

$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]].
public $booleanFormat

$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.
또한 보기: http://php.net/manual/en/intldateformatter.create.php
또한 보기: http://php.net/manual/en/class.intldateformatter.php#intl.intldateformatter-constants.calendartypes
또한 보기: http://php.net/manual/en/class.intlcalendar.php
부터: 2.0.7
public $calendar

$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.
public $currencyCode

$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
public $dateFormat

$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
public $datetimeFormat

$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 '.'.
public $decimalSeparator

$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.
부터: 2.0.1
public $defaultTimeZone

$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.
public $locale

$nullDisplay 공개적으로 프로퍼티

the text to be displayed when formatting a null value. Defaults to '(not set)', where (not set) will be translated according to [[locale]].
public $nullDisplay

$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, ]
public $numberFormatterOptions

$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 => '₽', ]
부터: 2.0.4
public $numberFormatterSymbols

$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', ]
public $numberFormatterTextOptions

$sizeFormatBase 공개적으로 프로퍼티

the base at which a kilobyte is calculated (1000 or 1024 bytes per kilobyte), used by [[asSize]] and [[asShortSize]]. Defaults to 1024.
public $sizeFormatBase

$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 ','.
public $thousandSeparator

$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
public $timeFormat

$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.
public $timeZone