Packages:
default
System
System.Caching
System.Collections
System.Data
System.Data.ActiveRecord
System.Data.ActiveRecord.Relations
System.Data.ActiveRecord.Scaffold
System.Data.ActiveReecord.Scaffold.InputBuilder
System.Data.Commom.Sqlite
System.Data.Common
System.Data.Common.Mssql
System.Data.Common.Mysql
System.Data.Common.Oracle
System.Data.Common.Pgsql
System.Data.Common.Sqlite
System.Data.DataGateway
System.Data.SqlMap
System.Data.SqlMap.Configuration
System.Data.SqlMap.Statements
System.Exceptions
System.I18N
System.IO
System.Security
System.Util
System.Web
System.Web.Services
System.Web.UI
System.Web.UI.ActiveControls
System.Web.UI.WebControls
System.Web.UI.WebControls.assets
System.Xml


Classes:
Keyword

Class TSimpleDateFormatter


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 1 to 31, no padding
  4. dd | Day of monath 01 to 31, zero leading
  5. M | Month digit 1 to 12, no padding
  6. MM | Month digit 01 to 12, zero leading
  7. yy | 2 year digit, e.g., 96, 05
  8. yyyy | 4 year digit, e.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");

Since: 3.0
Author: Wei Zhuo <weizhuo[at]gmail[dot]com>

Constructor Summary
public
__construct Array
Constructor, create a new date time formatter.

Method Summary
string
format ( string|int $value)
Format the date according to the pattern.
string
void
void
void
string
void
boolean
isValidDate ( mixed $value)
int
parse ( string|int $value, mixed $defaultToCurrentTime)
Parse the string according to the pattern.
void
setCharset ( string $charset)
void
setPattern ( string $pattern)

Constructor Details

__construct

public __construct Array

Constructor, create a new date time formatter.


Method Details

format

public string format (string|int $value )

Format the date according to the pattern.

Input
string|int$valuethe 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 ()

Output
Exception

getDayPattern

public void getDayPattern ()

Output
Exception

getMonthPattern

public void getMonthPattern ()

Output
Exception

getPattern

public string getPattern ()

Output
string formatting pattern.
Exception

getYearPattern

public void getYearPattern ()

Output
Exception

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$valuedate string or integer to parse
mixed$defaultToCurrentTime
Output
int date time stamp
Exception
throwsTInvalidDataValueException if date string is malformed.

setCharset

public void setCharset (string $charset )

Input
string$charsetformatting charset.
Output
Exception

setPattern

public void setPattern (string $pattern )

Input
string$patternformatting pattern.
Output
Exception