PHP Класс Prado\I18N\core\DateFormat

The DateFormat class allows you to format dates and times with predefined styles in a locale-sensitive manner. Formatting times with the DateFormat class is similar to formatting dates. Formatting dates with the DateFormat class is a two-step process. First, you create a formatter with the getDateInstance method. Second, you invoke the format method, which returns a string containing the formatted date. DateTime values are formatted using standard or custom patterns stored in the properties of a DateTimeFormatInfo.
Показать файл Открыть проект Примеры использования класса

Защищенные свойства (Protected)

Свойство Тип Описание
$formatInfo DateTimeFormatInfo The DateTimeFormatInfo, containing culture specific patterns and names.
$methods array A list of methods, to be used by the token function calls.
$tokens array A list of tokens and their function call.

Открытые методы

Метод Описание
__construct ( $formatInfo = null ) : DateFormat Initialize a new DateFormat.
format ( $time, $pattern = 'F', $charset = 'UTF-8' ) : string Format a date according to the pattern.

Защищенные методы

Метод Описание
getAMPM ( $date, $pattern = 'a' ) : string Get the AM/PM designator, 12 noon is PM, 12 midnight is AM.
getDay ( $date, $pattern = 'd' ) : string Get the day of the month.
getDayInMonth ( $date, $pattern = 'FF' ) : integer Get day in the month.
getDayInWeek ( $date, $pattern = 'EEEE' ) : string Get the day of the week.
getDayInYear ( $date, $pattern = 'D' ) : integer Get the day in the year, e.g. [1-366]
getEra ( $date, $pattern = 'G' ) : string Get the era. i.e. in gregorian, year > 0 is AD, else BC.
getFunctionName ( $token ) : mixed For a particular token, get the corresponding function to call.
getHour12 ( $date, $pattern = 'h' ) : string Get the hours in 12 hour format.
getHour24 ( $date, $pattern = 'H' ) : string Get the hours in 24 hour format, i.e. [0-23].
getHourInAMPM ( $date, $pattern = 'K' ) : integer Get the hours in AM/PM format, e.g [1-12]
getHourInDay ( $date, $pattern = 'k' ) : integer Get the hours [1-24].
getMinutes ( $date, $pattern = 'm' ) : string Get the minutes.
getMonth ( $date, $pattern = 'M' ) : string Get the month.
getPattern ( $pattern ) : string Get the pattern from DateTimeFormatInfo or some predefined patterns.
getSeconds ( $date, $pattern = 's' ) : string Get the seconds.
getTimeZone ( $date, $pattern = 'z' ) : string Get the timezone from the server machine.
getTokens ( $pattern ) : array Tokenize the pattern. The tokens are delimited by group of similar characters, e.g. 'aabb' will form 2 tokens of 'aa' and 'bb'.
getWeekInMonth ( $date, $pattern = 'W' ) : integer Get week in the month.
getWeekInYear ( $date, $pattern = 'w' ) : integer Get the week in the year.
getYear ( $date, $pattern = 'yyyy' ) : string Get the year.

Описание методов

__construct() публичный Метод

Initialize a new DateFormat.
public __construct ( $formatInfo = null ) : DateFormat
Результат DateFormat instance

format() публичный Метод

Format a date according to the pattern.
public format ( $time, $pattern = 'F', $charset = 'UTF-8' ) : string
Результат string formatted date time.

getAMPM() защищенный Метод

Get the AM/PM designator, 12 noon is PM, 12 midnight is AM.
protected getAMPM ( $date, $pattern = 'a' ) : string
Результат string AM or PM designator

getDay() защищенный Метод

"d" for non-padding, "dd" will always return 2 characters.
protected getDay ( $date, $pattern = 'd' ) : string
Результат string day of the month

getDayInMonth() защищенный Метод

Get day in the month.
protected getDayInMonth ( $date, $pattern = 'FF' ) : integer
Результат integer day in month

getDayInWeek() защищенный Метод

"E" will return integer 0 (for Sunday) through 6 (for Saturday). "EE" will return the narrow day of the week, e.g. "M" "EEE" will return the abrreviated day of the week, e.g. "Mon" "EEEE" will return the day of the week, e.g. "Monday"
protected getDayInWeek ( $date, $pattern = 'EEEE' ) : string
Результат string day of the week.

getDayInYear() защищенный Метод

Get the day in the year, e.g. [1-366]
protected getDayInYear ( $date, $pattern = 'D' ) : integer
Результат integer hours in AM/PM format.

getEra() защищенный Метод

Get the era. i.e. in gregorian, year > 0 is AD, else BC.
protected getEra ( $date, $pattern = 'G' ) : string
Результат string era

getFunctionName() защищенный Метод

For a particular token, get the corresponding function to call.
protected getFunctionName ( $token ) : mixed
Результат mixed the function if good token, null otherwise.

getHour12() защищенный Метод

"h" for non-padding, "hh" will always return 2 characters.
protected getHour12 ( $date, $pattern = 'h' ) : string
Результат string hours in 12 hour format.

getHour24() защищенный Метод

"H" for non-padding, "HH" will always return 2 characters.
protected getHour24 ( $date, $pattern = 'H' ) : string
Результат string hours in 24 hour format.

getHourInAMPM() защищенный Метод

Get the hours in AM/PM format, e.g [1-12]
protected getHourInAMPM ( $date, $pattern = 'K' ) : integer
Результат integer hours in AM/PM format.

getHourInDay() защищенный Метод

Get the hours [1-24].
protected getHourInDay ( $date, $pattern = 'k' ) : integer
Результат integer hours [1-24]

getMinutes() защищенный Метод

"m" for non-padding, "mm" will always return 2 characters.
protected getMinutes ( $date, $pattern = 'm' ) : string
Результат string minutes.

getMonth() защищенный Метод

"M" will return integer 1 through 12 "MM" will return the narrow month name, e.g. "J" "MMM" will return the abrreviated month name, e.g. "Jan" "MMMM" will return the month name, e.g. "January"
protected getMonth ( $date, $pattern = 'M' ) : string
Результат string month name

getPattern() защищенный Метод

If the $pattern parameter is an array of 2 element, it will assume that the first element is the date, and second the time and try to find an appropriate pattern and apply DateTimeFormatInfo::formatDateTime See the tutorial documentation for futher details on the patterns.
См. также: DateTimeFormatInfo::formatDateTime()
protected getPattern ( $pattern ) : string
Результат string a pattern.

getSeconds() защищенный Метод

"s" for non-padding, "ss" will always return 2 characters.
protected getSeconds ( $date, $pattern = 's' ) : string
Результат string seconds

getTimeZone() защищенный Метод

Get the timezone from the server machine.
protected getTimeZone ( $date, $pattern = 'z' ) : string
Результат string time zone

getTokens() защищенный Метод

Any substrings, starting and ending with a single quote (') will be treated as a single token.
protected getTokens ( $pattern ) : array
Результат array string tokens in an array.

getWeekInMonth() защищенный Метод

Get week in the month.
protected getWeekInMonth ( $date, $pattern = 'W' ) : integer
Результат integer week in month

getWeekInYear() защищенный Метод

Get the week in the year.
protected getWeekInYear ( $date, $pattern = 'w' ) : integer
Результат integer week in year

getYear() защищенный Метод

"yy" will return the last two digits of year. "yyyy" will return the full integer year.
protected getYear ( $date, $pattern = 'yyyy' ) : string
Результат string year

Описание свойств

$formatInfo защищенное свойство

The DateTimeFormatInfo, containing culture specific patterns and names.
protected DateTimeFormatInfo,Prado\I18N\core $formatInfo
Результат DateTimeFormatInfo

$methods защищенное свойство

A list of methods, to be used by the token function calls.
protected array $methods
Результат array

$tokens защищенное свойство

A list of tokens and their function call.
protected array $tokens
Результат array