PHP Class 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.
Afficher le fichier Open project: pradosoft/prado Class Usage Examples

Protected Properties

Свойство Type Description
$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.

Méthodes publiques

Méthode Description
__construct ( $formatInfo = null ) : DateFormat Initialize a new DateFormat.
format ( $time, $pattern = 'F', $charset = 'UTF-8' ) : string Format a date according to the pattern.

Méthodes protégées

Méthode Description
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.

Method Details

__construct() public méthode

Initialize a new DateFormat.
public __construct ( $formatInfo = null ) : DateFormat
Résultat DateFormat instance

format() public méthode

Format a date according to the pattern.
public format ( $time, $pattern = 'F', $charset = 'UTF-8' ) : string
Résultat string formatted date time.

getAMPM() protected méthode

Get the AM/PM designator, 12 noon is PM, 12 midnight is AM.
protected getAMPM ( $date, $pattern = 'a' ) : string
Résultat string AM or PM designator

getDay() protected méthode

"d" for non-padding, "dd" will always return 2 characters.
protected getDay ( $date, $pattern = 'd' ) : string
Résultat string day of the month

getDayInMonth() protected méthode

Get day in the month.
protected getDayInMonth ( $date, $pattern = 'FF' ) : integer
Résultat integer day in month

getDayInWeek() protected méthode

"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
Résultat string day of the week.

getDayInYear() protected méthode

Get the day in the year, e.g. [1-366]
protected getDayInYear ( $date, $pattern = 'D' ) : integer
Résultat integer hours in AM/PM format.

getEra() protected méthode

Get the era. i.e. in gregorian, year > 0 is AD, else BC.
protected getEra ( $date, $pattern = 'G' ) : string
Résultat string era

getFunctionName() protected méthode

For a particular token, get the corresponding function to call.
protected getFunctionName ( $token ) : mixed
Résultat mixed the function if good token, null otherwise.

getHour12() protected méthode

"h" for non-padding, "hh" will always return 2 characters.
protected getHour12 ( $date, $pattern = 'h' ) : string
Résultat string hours in 12 hour format.

getHour24() protected méthode

"H" for non-padding, "HH" will always return 2 characters.
protected getHour24 ( $date, $pattern = 'H' ) : string
Résultat string hours in 24 hour format.

getHourInAMPM() protected méthode

Get the hours in AM/PM format, e.g [1-12]
protected getHourInAMPM ( $date, $pattern = 'K' ) : integer
Résultat integer hours in AM/PM format.

getHourInDay() protected méthode

Get the hours [1-24].
protected getHourInDay ( $date, $pattern = 'k' ) : integer
Résultat integer hours [1-24]

getMinutes() protected méthode

"m" for non-padding, "mm" will always return 2 characters.
protected getMinutes ( $date, $pattern = 'm' ) : string
Résultat string minutes.

getMonth() protected méthode

"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
Résultat string month name

getPattern() protected méthode

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.
See also: DateTimeFormatInfo::formatDateTime()
protected getPattern ( $pattern ) : string
Résultat string a pattern.

getSeconds() protected méthode

"s" for non-padding, "ss" will always return 2 characters.
protected getSeconds ( $date, $pattern = 's' ) : string
Résultat string seconds

getTimeZone() protected méthode

Get the timezone from the server machine.
protected getTimeZone ( $date, $pattern = 'z' ) : string
Résultat string time zone

getTokens() protected méthode

Any substrings, starting and ending with a single quote (') will be treated as a single token.
protected getTokens ( $pattern ) : array
Résultat array string tokens in an array.

getWeekInMonth() protected méthode

Get week in the month.
protected getWeekInMonth ( $date, $pattern = 'W' ) : integer
Résultat integer week in month

getWeekInYear() protected méthode

Get the week in the year.
protected getWeekInYear ( $date, $pattern = 'w' ) : integer
Résultat integer week in year

getYear() protected méthode

"yy" will return the last two digits of year. "yyyy" will return the full integer year.
protected getYear ( $date, $pattern = 'yyyy' ) : string
Résultat string year

Property Details

$formatInfo protected_oe property

The DateTimeFormatInfo, containing culture specific patterns and names.
protected DateTimeFormatInfo,Prado\I18N\core $formatInfo
Résultat DateTimeFormatInfo

$methods protected_oe property

A list of methods, to be used by the token function calls.
protected array $methods
Résultat array

$tokens protected_oe property

A list of tokens and their function call.
protected array $tokens
Résultat array