Class CDateFormatter
CDateFormatter provides date/time localization functionalities.
CDateFormatter allows you to format dates and times in a locale-sensitive manner. Patterns are interpreted in the locale that the CDateFormatter instance is associated with. For example, month names and weekday names may vary under different locales, which yields different formatting results. The patterns that CDateFormatter recognizes are as defined in CLDR.
CDateFormatter supports predefined patterns as well as customized ones:- The method
CDateFormatter::formatDateTime()
formats date or time or both using predefined patterns which include 'full', 'long', 'medium' (default) and 'short'. - The method
CDateFormatter::format()
formats datetime using the specified pattern. See http://www.unicode.org/reports/tr35/#Date_Format_Patterns for details about the recognized pattern characters.
- CComponent
- CDateFormatter
Copyright: 2008-2013 Yii Software LLC
License: http://www.yiiframework.com/license/
Author: Wei Zhuo <weizhuo[at]gmail[dot]com>
Author: Qiang Xue <qiang.xue@gmail.com>
Since: 1.0
Located at x2engine/framework/i18n/CDateFormatter.php
public
|
|
public
string
|
|
public
string
|
#
formatDateTime( mixed $timestamp, string $dateWidth = 'medium', string $timeWidth = 'medium' )
Formats a date according to a predefined pattern. The predefined pattern is determined based on the date pattern width and time pattern width. |
protected
array
|
|
protected
string
|
#
formatYear( string $pattern, array $date )
Get the year. "yy" will return the last two digits of year. "y...y" will pad the year with 0 in the front, e.g. "yyyyy" will generate "02008" for year 2008. |
protected
string
|
#
formatMonth( string $pattern, array $date )
Get the month. "M" will return integer 1 through 12; "MM" will return two digits month number with necessary zero padding, e.g. 05; "MMM" will return the abrreviated month name, e.g. "Jan"; "MMMM" will return the full month name, e.g. "January"; "MMMMM" will return the narrow month name, e.g. "J"; |
protected
string
|
|
protected
integer
|
|
protected
integer
|
#
formatDayInMonth( string $pattern, array $date )
Get day of week in the month, e.g. 2nd Wed in July. |
protected
string
|
#
formatDayInWeek( string $pattern, array $date )
Get the day of the week. "E", "EE", "EEE" will return abbreviated week day name, e.g. "Tues"; "EEEE" will return full week day name; "EEEEE" will return the narrow week day name, e.g. "T"; |
protected
string
|
#
formatPeriod( string $pattern, array $date )
Get the AM/PM designator, 12 noon is PM, 12 midnight is AM. |
protected
string
|
#
formatHour24( string $pattern, array $date )
Get the hours in 24 hour format, i.e. [0-23]. "H" for non-padding, "HH" will always return 2 characters. |
protected
string
|
#
formatHour12( string $pattern, array $date )
Get the hours in 12 hour format, i.e., [1-12] "h" for non-padding, "hh" will always return 2 characters. |
protected
integer
|
#
formatHourInDay( string $pattern, array $date )
Get the hours [1-24]. 'k' for non-padding, and 'kk' with 2 characters padding. |
protected
integer
|
#
formatHourInPeriod( string $pattern, array $date )
Get the hours in AM/PM format, e.g [0-11] "K" for non-padding, "KK" will always return 2 characters. |
protected
string
|
#
formatMinutes( string $pattern, array $date )
Get the minutes. "m" for non-padding, "mm" will always return 2 characters. |
protected
string
|
#
formatSeconds( string $pattern, array $date )
Get the seconds. "s" for non-padding, "ss" will always return 2 characters. |
protected
integer
|
|
protected
integer
|
|
protected
string
|
|
protected
string
|