Overview

Packages

  • application
    • commands
    • components
      • actions
      • filters
      • leftWidget
      • permissions
      • sortableWidget
      • util
      • webupdater
      • x2flow
        • actions
        • triggers
      • X2GridView
      • X2Settings
    • controllers
    • models
      • embedded
    • modules
      • accounts
        • controllers
        • models
      • actions
        • controllers
        • models
      • calendar
        • controllers
        • models
      • charts
        • models
      • contacts
        • controllers
        • models
      • docs
        • components
        • controllers
        • models
      • groups
        • controllers
        • models
      • marketing
        • components
        • controllers
        • models
      • media
        • controllers
        • models
      • mobile
        • components
      • opportunities
        • controllers
        • models
      • products
        • controllers
        • models
      • quotes
        • controllers
        • models
      • services
        • controllers
        • models
      • template
        • models
      • users
        • controllers
        • models
      • workflow
        • controllers
        • models
      • x2Leads
        • controllers
        • models
  • Net
  • None
  • PHP
  • system
    • base
    • caching
      • dependencies
    • collections
    • console
    • db
      • ar
      • schema
        • cubrid
        • mssql
        • mysql
        • oci
        • pgsql
        • sqlite
    • i18n
      • gettext
    • logging
    • test
    • utils
    • validators
    • web
      • actions
      • auth
      • filters
      • form
      • helpers
      • renderers
      • services
      • widgets
        • captcha
        • pagers
  • Text
    • Highlighter
  • zii
    • behaviors
    • widgets
      • grid
      • jui

Classes

  • CDateTimeParser
  • CFileHelper
  • CFormatter
  • CLocalizedFormatter
  • CMarkdownParser
  • CPasswordHelper
  • CPropertyValue
  • CTimestamp
  • CVarDumper
  • Overview
  • Package
  • Class
  • Tree

Class CDateTimeParser

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
MMM     | Abbreviation representation of month (available since 1.1.11; locale aware since 1.1.13)
MMMM    | Full name representation (available since 1.1.13; locale aware)
y       | 4 year digit, e.g., 2005 (available since 1.1.16)
yy      | 2 year digit, e.g., 96, 05
yyyy    | 4 year digit, e.g., 2005
h       | Hour in 0 to 23, no padding
hh      | Hour in 00 to 23, zero leading
H       | Hour in 0 to 23, no padding
HH      | Hour in 00 to 23, zero leading
m       | Minutes in 0 to 59, no padding
mm      | Minutes in 00 to 59, zero leading
s       | Seconds in 0 to 59, no padding
ss      | Seconds in 00 to 59, zero leading
a       | AM or PM, case-insensitive (since version 1.1.5)
?       | matches any character (wildcard) (since version 1.1.11)
----------------------------------------------------

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');

Locale specific patterns such as MMM and MMMM uses CLocale for retrieving needed information.

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

Package: system\utils
Copyright: 2008-2013 Yii Software LLC
License: http://www.yiiframework.com/license/
Author: Wei Zhuo <weizhuo[at]gmail[dot]com>
Author: Qiang Xue <qiang.xue@gmail.com>
Since: 1.0
Located at x2engine/framework/utils/CDateTimeParser.php
Methods summary
public static integer
# parse( string $value, string $pattern = 'MM/dd/yyyy', array $defaults = array() )

Converts a date string to a timestamp.

Converts a date string to a timestamp.

Parameters

$value
string
$value the date string to be parsed
$pattern
string
$pattern the pattern that the date string is following
$defaults
array
$defaults the default values for year, month, day, hour, minute and second. The default values will be used in case when the pattern doesn't specify the corresponding fields. For example, if the pattern is 'MM/dd/yyyy' and this parameter is array('minute'=>0, 'second'=>0), then the actual minute and second for the parsing result will take value 0, while the actual hour value will be the current hour obtained by date('H'). This parameter has been available since version 1.1.5.

Returns

integer
timestamp for the date string. False if parsing fails.
public static
# tokenize( mixed $pattern )
protected static string
# parseInteger( string $value, integer $offset, integer $minLength, integer $maxLength )

Parameters

$value
string
$value the date string to be parsed
$offset
integer
$offset starting offset
$minLength
integer
$minLength minimum length
$maxLength
integer
$maxLength maximum length

Returns

string
parsed integer value
protected static string
# parseAmPm( string $value, integer $offset )

Parameters

$value
string
$value the date string to be parsed
$offset
integer
$offset starting offset

Returns

string
parsed day period value
protected static string
# parseMonth( string $value, integer $offset, string $width, string & $monthName )

Parameters

$value
string
$value the date string to be parsed.
$offset
integer
$offset starting offset.
$width
string
$width month name width. It can be 'wide', 'abbreviated' or 'narrow'.
$monthName
string
$monthName extracted month name. Passed by reference.

Returns

string
parsed month name.

Since

1.1.13
API documentation generated by ApiGen 2.8.0