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");
Show file
Open project: pradosoft/prado
Class Usage Examples
Method | 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 ) |
Method | 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. |
public __construct ( $pattern, $charset = 'UTF-8' ) |
public isValidDate ( $value ) : boolean | ||
return | boolean | true if the given value matches with the date pattern. |