PHP Class 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");
Since: 3.0
Afficher le fichier Open project: pradosoft/prado Class Usage Examples

Méthodes publiques

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

Private Methods

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

Method Details

__construct() public méthode

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

format() public méthode

Format the date according to the pattern.
public format ( $value ) : string
Résultat string formatted date.

getCharset() public méthode

public getCharset ( ) : string
Résultat string formatting charset.

getDayMonthYearOrdering() public méthode

getDayPattern() public méthode

public getDayPattern ( )

getMonthPattern() public méthode

public getMonthPattern ( )

getPattern() public méthode

public getPattern ( ) : string
Résultat string formatting pattern.

getYearPattern() public méthode

public getYearPattern ( )

isValidDate() public méthode

public isValidDate ( $value ) : boolean
Résultat boolean true if the given value matches with the date pattern.

parse() public méthode

Parse the string according to the pattern.
public parse ( $value, $defaultToCurrentTime = true ) : integer
Résultat integer date time stamp

setCharset() public méthode

public setCharset ( $charset )

setPattern() public méthode

public setPattern ( $pattern )