PHP Класс Prado\Util\TSimpleDateFormatter

Formats and parses dates using the SimpleDateFormat pattern. This pattern is compatible with the I18N and java's SimpleDateFormatter. Pattern | Description ---------------------------------------------------- d | Day of month 1 to 31, no padding dd | Day of monath 01 to 31, zero leading M | Month digit 1 to 12, no padding MM | Month digit 01 to 12, zero leading yy | 2 year digit, e.g., 96, 05 yyyy | 4 year digit, e.g., 2005 ---------------------------------------------------- Usage example, to format a date $formatter = new TSimpleDateFormatter("dd/MM/yyy"); echo $formatter->format(time()); To parse the date string into a date timestamp. $formatter = new TSimpleDateFormatter("d-M-yyy"); echo $formatter->parse("24-6-2005");
С версии: 3.0
Показать файл Открыть проект Примеры использования класса

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

Метод Описание
__construct ( $pattern, $charset = 'UTF-8' ) Constructor, create a new date time formatter.
format ( $value ) : string Format the date according to the pattern.
getCharset ( ) : string
getDayMonthYearOrdering ( )
getDayPattern ( )
getMonthPattern ( )
getPattern ( ) : string
getYearPattern ( )
isValidDate ( $value ) : boolean
parse ( $value, $defaultToCurrentTime = true ) : integer Parse the string according to the pattern.
setCharset ( $charset )
setPattern ( $pattern )

Приватные методы

Метод Описание
charAt ( $string, $pos ) Get the char at a position.
charEqual ( $string, $pos, $char ) Returns true if char at position equals a particular char.
getDate ( $value ) : array Gets the time stamp from string or integer.
getInteger ( $str, $i, $minlength, $maxlength ) : string Gets integer from part of a string, allows integers of any length.
length ( $string ) Calculate the length of a string, may be consider iconv_strlen?
substring ( $string, $start, $length ) Gets a portion of a string, uses iconv_substr.

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

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

Constructor, create a new date time formatter.
public __construct ( $pattern, $charset = 'UTF-8' )

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

Format the date according to the pattern.
public format ( $value ) : string
Результат string formatted date.

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

public getCharset ( ) : string
Результат string formatting charset.

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

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

public getDayPattern ( )

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

public getMonthPattern ( )

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

public getPattern ( ) : string
Результат string formatting pattern.

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

public getYearPattern ( )

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

public isValidDate ( $value ) : boolean
Результат boolean true if the given value matches with the date pattern.

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

Parse the string according to the pattern.
public parse ( $value, $defaultToCurrentTime = true ) : integer
Результат integer date time stamp

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

public setCharset ( $charset )

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

public setPattern ( $pattern )