PHP Class Contao\Date

The class converts arbitrary date strings to Unix timestamps and provides extended information like the begin or end of the day, week, month or year. Usage: $date = new Date(); echo $date->datim; $date = new Date('2011-09-18', 'Y-m-d'); echo $date->monthBegin; Date::formatToJs('m/d/Y H:i');
Afficher le fichier Open project: contao/core-bundle Class Usage Examples

Protected Properties

Свойство Type Description
$arrRange array Date range
$strDate integer Date string
$strFormat string Format string

Méthodes publiques

Méthode Description
__construct ( integer $strDate = null, string $strFormat = null ) Set the object properties
__get ( string $strKey ) : mixed | null Return an object property
floorToMinute ( integer $intTime = null ) : integer Round a UNIX timestamp to the full minute
formatToJs ( string $strFormat ) : mixed Convert a PHP format string into a JavaScript format string
getFormatFromRgxp ( string $strRgxp ) : string Return a numeric format string depending on the regular expression name
getInputFormat ( string $strFormat = null ) : string Return an input format string for a particular date (e.g. YYYY-MM-DD)
getNumericDateFormat ( ) : string Return the numeric date format string
getNumericDatimFormat ( ) : string Return the numeric datim format string
getNumericTimeFormat ( ) : string Return the numeric time format string
getRegexp ( string $strFormat = null ) : string Return a regular expression to check a date
getWeekBegin ( integer $intStartDay ) : integer Return the begin of the week as timestamp
getWeekEnd ( integer $intStartDay ) : integer Return the end of the week as timestamp
isNumericFormat ( string $strFormat ) : boolean Check for a numeric date format
parse ( string $strFormat, integer $intTstamp = null ) : string Parse a date format string and translate textual representations

Méthodes protégées

Méthode Description
createDateRanges ( ) Create the date ranges
dateToUnix ( ) Convert a date string into a Unix timestamp using the format string
resolveCustomModifiers ( string $strDate ) : string Resolve the custom modifiers

Method Details

__construct() public méthode

Set the object properties
public __construct ( integer $strDate = null, string $strFormat = null )
$strDate integer An optional date string
$strFormat string An optional format string

__get() public méthode

Return an object property
public __get ( string $strKey ) : mixed | null
$strKey string The property name
Résultat mixed | null The property value

createDateRanges() protected méthode

Create the date ranges
protected createDateRanges ( )

dateToUnix() protected méthode

Convert a date string into a Unix timestamp using the format string
protected dateToUnix ( )

floorToMinute() public static méthode

Round a UNIX timestamp to the full minute
public static floorToMinute ( integer $intTime = null ) : integer
$intTime integer The timestamp
Résultat integer The rounded timestamp

formatToJs() public static méthode

Convert a PHP format string into a JavaScript format string
public static formatToJs ( string $strFormat ) : mixed
$strFormat string The PHP format string
Résultat mixed The JavaScript format string

getFormatFromRgxp() public static méthode

Return a numeric format string depending on the regular expression name
public static getFormatFromRgxp ( string $strRgxp ) : string
$strRgxp string The regular expression name
Résultat string The numeric format string

getInputFormat() public static méthode

Return an input format string for a particular date (e.g. YYYY-MM-DD)
public static getInputFormat ( string $strFormat = null ) : string
$strFormat string An optional format string
Résultat string The input format string

getNumericDateFormat() public static méthode

Return the numeric date format string
public static getNumericDateFormat ( ) : string
Résultat string The numeric date format string

getNumericDatimFormat() public static méthode

Return the numeric datim format string
public static getNumericDatimFormat ( ) : string
Résultat string The numeric datim format string

getNumericTimeFormat() public static méthode

Return the numeric time format string
public static getNumericTimeFormat ( ) : string
Résultat string The numeric time format string

getRegexp() public static méthode

Return a regular expression to check a date
public static getRegexp ( string $strFormat = null ) : string
$strFormat string An optional format string
Résultat string The regular expression string

getWeekBegin() public méthode

Return the begin of the week as timestamp
public getWeekBegin ( integer $intStartDay ) : integer
$intStartDay integer The week start day
Résultat integer The Unix timestamp

getWeekEnd() public méthode

Return the end of the week as timestamp
public getWeekEnd ( integer $intStartDay ) : integer
$intStartDay integer The week start day
Résultat integer The Unix timestamp

isNumericFormat() public static méthode

Check for a numeric date format
public static isNumericFormat ( string $strFormat ) : boolean
$strFormat string The PHP format string
Résultat boolean True if the date format is numeric

parse() public static méthode

Parse a date format string and translate textual representations
public static parse ( string $strFormat, integer $intTstamp = null ) : string
$strFormat string The date format string
$intTstamp integer An optional timestamp
Résultat string The textual representation of the date

resolveCustomModifiers() protected static méthode

Resolve the custom modifiers
protected static resolveCustomModifiers ( string $strDate ) : string
$strDate string The date string
Résultat string The resolved date string

Property Details

$arrRange protected_oe property

Date range
protected array $arrRange
Résultat array

$strDate protected_oe property

Date string
protected int $strDate
Résultat integer

$strFormat protected_oe property

Format string
protected string $strFormat
Résultat string