CDateParser

Package system.utils
Inheritance class CDateParser
Since 1.0
Version $Id: CDateParser.php 724 2009-02-21 18:20:34Z qiang.xue $
CDateParser converts a date string to a UNIX timestamp according to the specified pattern.

The following pattern characters are recognized:
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
----------------------------------------------------
All other characters must appear in the date string at the corresponding positions.

For example, to parse a date string '21/10/2008', use the following:
$timestamp=CDateParser::parse('21/10/2008','dd/MM/yyyy');


To format a timestamp to a date string, please use CDateFormatter.

Public Methods

Hide inherited methods

MethodDescriptionDefined By
parse() Converts a date string to a timestamp. CDateParser

Protected Methods

Hide inherited methods

MethodDescriptionDefined By
parseInteger() CDateParser

Method Details

parse() method
public static integer parse(string $value, string $pattern='MM/dd/yyyy')
$value string the date string to be parsed
$pattern string the pattern that the date string is following
{return} integer timestamp for the date string. False if parsing fails.

Converts a date string to a timestamp.

parseInteger() method
protected static void parseInteger($value, $offset, $minLength, $maxLength)
$value
$offset
$minLength
$maxLength