- Home
- About
- Testimonials
- Demos
- Download
- Documentation
- Blogs
- Forum
- Support

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: TBrowserLogRoute TDataFieldAccessor TDateTimeStamp TDbLogRoute TEmailLogRoute TFileLogRoute TFirebugLogRoute TFirePhpLogRoute TLogger TLogRoute TLogRouter TParameterModule TSimpleDateFormatter TVarDumper |
Keyword
# Class TSimpleDateFormatter
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 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 | getCharset ()
void | getDayMonthYearOrdering ()
void | getDayPattern ()
void | getMonthPattern ()
string | getPattern ()
void | getYearPattern ()
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 | $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 | ()
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 | $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