\Field\UtilityDateToolbox

DateToolbox class for handling date related tasks.

Summary

Methods
Properties
Constants
createFromFormat()
normalizeFormat()
validateDateFormat()
validateTimeFormat()
getPHPFormat()
No public properties found
No constants found
No protected methods found
$_map
N/A
No private methods found
No private properties found
N/A

Properties

$_map

$_map : array

Maps jQuery's datepicker format tokens to PHP's

Type

array

Methods

createFromFormat()

createFromFormat(string $format, string $date) : \DateTime|false

Converts the given $date to a valid PHP's DateTime object using a jQuery's date/time $format.

Parameters

string $format

A jQuery's date/time format. e.g. 'today is:' yy-mm-dd

string $date

A date formatted using $format. e.g. today is: 2015-01-30

Returns

\DateTime|false —

Date object on success, false on error

normalizeFormat()

normalizeFormat(string $format) : string

Converts jQuery's date/time format to PHP's.

Parameters

string $format

Date format coming from jQuery's datepicker widget. e.g. yy-mm-dd hh:mm

Returns

string —

A valid date/time format to use with PHP

validateDateFormat()

validateDateFormat(string $format) : boolean

Validates a date format for jQuery's datepicker widget.

Parameters

string $format

Format to validate. e.g. yy:mm:ddQ (invalid)

Returns

boolean

validateTimeFormat()

validateTimeFormat(string $format) : boolean

Validates a time format for jQuery's datepicker widget.

Parameters

string $format

Format to validate. e.g. hh:mm:ssA (invalid)

Returns

boolean

getPHPFormat()

getPHPFormat(\Cake\Datasource\EntityInterface $field) : string

Given a DateField instance, gets its PHP's date-format.

Parameters

\Cake\Datasource\EntityInterface $field

DateField instance

Returns

string —

PHP date-format for later use with date() function