Class TSimpleDateFormatter

Description

TSimpleDateFormatter class.

Formats and parses dates using the SimpleDateFormat pattern. This pattern is compatible with the I18N and java's SimpleDateFormatter.

  1.  Pattern |      Description
  2.  ----------------------------------------------------
  3.  d       Day of month to 31no padding
  4.  dd      Day of monath 01 to 31zero leading
  5.  M       Month digit to 12no padding
  6.  MM      Month digit 01 to 12zero leading
  7.  yy      year digite.g.9605
  8.  yyyy    year digite.g.2005
  9.  ----------------------------------------------------

Usage example, to format a date

  1.  $formatter new TSimpleDateFormatter("dd/MM/yyy");
  2.  echo $formatter->format(time());

To parse the date string into a date timestamp.

  1.  $formatter new TSimpleDateFormatter("d-M-yyy");
  2.  echo $formatter->parse("24-6-2005");

  • author: Wei Zhuo <weizhuo[at]gmail[dot]com>
  • version: $Id: TSimpleDateFormatter.php 2996 2011-06-20 15:24:57Z ctrlaltca@gmail.com $
  • since: 3.0

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 getDayPattern ()
void getMonthPattern ()
string getPattern ()
void getYearPattern ()
boolean isValidDate ( $value)
int parse (string|int $value, [ $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 ( $value)
  • $value
parse (line 205)

Parse the string according to the pattern.

  • return: date time stamp
  • throws: TInvalidDataValueException if date string is malformed.
  • access: public
int parse (string|int $value, [ $defaultToCurrentTime = true])
  • string|int $value: date string or integer to parse
  • $defaultToCurrentTime
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, 25 Jun 2012 14:39:12 +0200 by phpDocumentor 1.4.3