PRADO Component Framework for PHP 5
  • Home
  • About
  • Testimonials
  • Demos
  • Download
  • Documentation
  • Forum
  • Development
  • Tutorials
  • Class Docs
  • API Manual
  • Wiki

Packages

  • None
  • System
    • Caching
    • Collections
    • Data
      • ActiveRecord
        • Relations
        • Scaffold
          • InputBuilder
      • Commom
        • Sqlite
      • Common
        • Mssql
        • Mysql
        • Oracle
        • Pgsql
        • Sqlite
      • DataGateway
      • SqlMap
        • Configuration
        • Statements
    • Exceptions
    • I18N
    • IO
    • Security
    • Util
    • Web
      • Javascripts
      • Services
      • UI
        • ActiveControls
        • WebControls
    • Xml
  • Wsat
    • pages
  • Overview
  • Package
  • Class
  • Tree
  • Deprecated
  • Todo

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");
Package: System\Util
Copyright: Copyright © 2005-2014 PradoSoft
License: http://www.pradosoft.com/license/
Author: Wei Zhuo <weizhuo[at]gmail[dot]com>
Since: 3.0
Located at Util/TSimpleDateFormatter.php
Methods summary
public
# __construct( string $pattern, string $charset = 'UTF-8' )

Constructor, create a new date time formatter.

Constructor, create a new date time formatter.

Parameters

$pattern
string
formatting pattern.
$charset
string
pattern and value charset
public string
# getPattern( )

Returns

string
formatting pattern.
public
# setPattern( string $pattern )

Parameters

$pattern
string
formatting pattern.
public string
# getCharset( )

Returns

string
formatting charset.
public
# setCharset( string $charset )

Parameters

$charset
string
formatting charset.
public string
# format( string|integer $value )

Format the date according to the pattern.

Format the date according to the pattern.

Parameters

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

Returns

string
formatted date.
public
# getMonthPattern( )
public
# getDayPattern( )
public
# getYearPattern( )
public
# getDayMonthYearOrdering( )
public boolean
# isValidDate( mixed $value )

Returns

boolean
true if the given value matches with the date pattern.
public integer
# parse( string|integer $value, mixed $defaultToCurrentTime = true )

Parse the string according to the pattern.

Parse the string according to the pattern.

Parameters

$value
string|integer
date string or integer to parse
$defaultToCurrentTime

Returns

integer
date time stamp

Throws

TInvalidDataValueException
if date string is malformed.
Terms of Service | Contact Us
PRADO v3.2.4 API Manual API documentation generated by ApiGen 2.8.0
Copyright © 2006-2014 by the PRADO Group.
Powered by PRADO