system system.base system.caching system.caching.dependencies system.collections system.console system.db system.db.ar system.db.schema system.db.schema.mssql system.db.schema.mysql system.db.schema.oci system.db.schema.pgsql system.db.schema.sqlite system.i18n system.i18n.gettext system.logging system.utils system.validators system.web system.web.actions system.web.auth system.web.filters system.web.helpers system.web.renderers system.web.services system.web.widgets system.web.widgets.captcha system.web.widgets.pagers

CDateTimeParser

system.utils
继承 class CDateTimeParser
可用自 1.0
版本 $Id$
CDateTimeParser converts a date/time 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 month 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
h       | Hour in 0 to 23, no padding (since version 1.0.5)
hh      | Hour in 00 to 23, zero leading (since version 1.0.5)
H       | Hour in 0 to 23, no padding (since version 1.0.9)
HH      | Hour in 00 to 23, zero leading (since version 1.0.9)
m       | Minutes in 0 to 59, no padding (since version 1.0.5)
mm      | Minutes in 00 to 59, zero leading (since version 1.0.5)
s	   | Seconds in 0 to 59, no padding (since version 1.0.5)
ss      | Seconds in 00 to 59, zero leading (since version 1.0.5)
----------------------------------------------------
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=CDateTimeParser::parse('21/10/2008','dd/MM/yyyy');


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

公共方法

隐藏继承的方法

方法描述被定义在
parse() Converts a date string to a timestamp. CDateTimeParser

受保护的方法

隐藏继承的方法

方法描述被定义在
parseInteger() CDateTimeParser

方法详情

parse() 方法
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() 方法
protected static void parseInteger($value, $offset, $minLength, $maxLength)
$value
$offset
$minLength
$maxLength