## Class TSimpleDateFormatter

Description

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

     $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
- version: $Id: TSimpleDateFormatter.php 1980 2007-05-30 23:27:00Z knut $
- author: Wei Zhuo <weizhuo[at]gmail[dot]com>

Located in /Util/TSimpleDateFormatter.php (line 47)

Method Summary
TSimpleDateFormatter __construct (string $pattern, [string $charset = 'UTF-8'])
string format (string|int $value)
string getCharset ()
void getDayMonthYearOrdering ()
void getDayPattern ()
void getMonthPattern ()
string getPattern ()
void getYearPattern ()
boolean isValidDate (mixed $value)
int parse (string|int $value, [mixed $defaultToCurrentTime = true])
void setCharset (string $charset)
void setPattern (string $pattern)
Methods
Constructor __construct (line 66)

Constructor, create a new date time formatter.

- access: public

TSimpleDateFormatter __construct (string $pattern, [string $charset = 'UTF-8'])

- string $pattern: formatting pattern.
- string $charset: pattern and value charset

format (line 109)

Format the date according to the pattern.

- return: formatted date.
- access: public

string format (string|int $value)

- string|int $value: the date to format, either integer or a string readable by strtotime.

getCharset (line 91)

- return: formatting charset.
- access: public

string getCharset ()
getDayMonthYearOrdering (line 156)

- access: public

void getDayMonthYearOrdering ()
getDayPattern (line 138)

- access: public

void getDayPattern ()
getMonthPattern (line 125)

- access: public

void getMonthPattern ()
getPattern (line 75)

- return: formatting pattern.
- access: public

string getPattern ()
getYearPattern (line 147)

- access: public

void getYearPattern ()
isValidDate (line 190)

- return: true if the given value matches with the date pattern.
- access: public

boolean isValidDate (mixed $value)
parse (line 204)

Parse the string according to the pattern.

- return: date time stamp
- access: public
- throws: TInvalidDataValueException if date string is malformed.

int parse (string|int $value, [mixed $defaultToCurrentTime = true])

- string|int $value: date string or integer to parse

setCharset (line 99)

- access: public

void setCharset (string $charset)

- string $charset: formatting charset.

setPattern (line 83)

- access: public

void setPattern (string $pattern)

- string $pattern: formatting pattern.

Documentation generated on Mon, 21 Apr 2008 11:36:11 -0400 by phpDocumentor 1.3.0RC4