TSimpleDateFormatter class.
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
To parse the date string into a date timestamp.
| Method Details |
format
| public string format |
(string|int $value ) |
Format the date according to the pattern.
| Input |
| string|int | $value | the date to format, either integer or a string readable by strtotime. |
| Output |
|
string
| formatted date. |
| Exception |
|
getCharset
| public string getCharset |
() |
| Output |
|
string
| formatting charset. |
| Exception |
|
getDayMonthYearOrdering
| public void getDayMonthYearOrdering |
() |
|
getDayPattern
| public void getDayPattern |
() |
|
getMonthPattern
| public void getMonthPattern |
() |
|
getPattern
| public string getPattern |
() |
| Output |
|
string
| formatting pattern. |
| Exception |
|
getYearPattern
| public void getYearPattern |
() |
|
isValidDate
| public boolean isValidDate |
(mixed $value ) |
| Input |
| mixed | $value | |
| Output |
|
boolean
| true if the given value matches with the date pattern. |
| Exception |
|
parse
| public int parse |
(string|int $value , mixed $defaultToCurrentTime ) |
Parse the string according to the pattern.
| Input |
| string|int | $value | date string or integer to parse |
| mixed | $defaultToCurrentTime | |
| Output |
|
int
| date time stamp |
| Exception |
| throws | TInvalidDataValueException if date string is malformed. |
|
setCharset
| public void setCharset |
(string $charset ) |
| Input |
| string | $charset | formatting charset. |
| Output |
| Exception |
|
setPattern
| public void setPattern |
(string $pattern ) |
| Input |
| string | $pattern | formatting pattern. |
| Output |
| Exception |
|