Message-ID: <1083152405.3894.1485855813450.JavaMail.confluence@ip-10-127-227-164> Subject: Exported From Confluence MIME-Version: 1.0 Content-Type: multipart/related; boundary="----=_Part_3893_2076755479.1485855813449" ------=_Part_3893_2076755479.1485855813449 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Content-Location: file:///C:/exported.html The DateAndTime FieldType

The DateAndTime FieldType

This FieldType represents a full date including time information= .

Name Internal name Expected input type
DateAndTime ezdatetime mixed

Table of contents:

=20 =20

Description


This FieldType makes possible to store and retrieve a full date includin= g time information.

Input expectations

If input value is of type string or integer, it will be passed directly to the PHP's built-in \DateTime class constructor, therefore the same inpu= t format expectations apply.

It is also possible to directly pass an instance of \DateT= ime.

Type Example
string "2012-08-28 12:20 Europe/Berlin"
integer
1346149200
\DateTime
new \DateTime()

Value object


Properties

The Value class of this field type contains the following properties:

Property Type Description
$value \DateTime The date and time value as an inst= ance of \DateTime.

Constructor

The constructor for this value object will initialize a new Value o= bject with the value provided. It accepts an instance of PHP's built-in&nbs= p;\DateTime class.

String representati= on

String representation of the date value will generate the date string in= the format "D Y-d-m H:i:s" as accepted by PH= P's built-in date() function.

Example:

Wed 2013-22-05 12:19:18


Hash format


Hash value of this FieldType is an array with two keys:

Key Type Description Example

t= imestamp

integer Time information as a timestamp= .

1400856992

=

r= fc850

string

Time information as a string in R= FC 850 date format.

As input, this will have higher precedence ov= er the timestamp value.

"Friday, 23-May-14 14:56:14 = GMT+0000"
=20
$hash =3D array(
=09"timestamp" =3D> 1400856992,
=09"rfc850" =3D> "Friday, 23-May-14 14:56:14 GMT+0000"
);
=20

Validation


This FieldType does not perform any special validation of the input valu= e.

Settings


The field definition of this FieldType can be configured with several op= tions:

Name Type Default value Description
useSeconds boolean false Used to control displaying of seco= nds in the output.
defaultType
mixed
Type::DEFAULT_EMPTY

One of the DEFAUL= T_* constants, used by the administration interface for set= ting the default field value.

See below for more details.

dateInterval
null|\DateInterval
null

This setting complements defaultType setting and can be used only when latte= r is set to Type::DEFAULT_CURRENT_DATE_ADJUSTED.

In that case the default input value when using administration in= terface will be adjusted by the given \DateInterval.

Following defaultType default value options are available as constants in the=  eZ\Publish\Cor= e\FieldType\DateAndTime\Type class:

Constant Description
DEFAULT_EMPTY
Default value will be empty.
DEFAULT_CURRENT_DATE
Default value will use current date.
DEFAULT_CURRENT_DATE_ADJUSTED
Default value will use current date,= adjusted by the interval defined in dateInterval setting.
DateAndTime FieldType example settings
=20
use eZ\Publish\Core\FieldType\DateAndTime\Type;

$settings =3D array(
=09"useSeconds" =3D> false,
=09"defaultType" =3D> Type::DEFAULT_EMPTY,
=09"dateInterval" =3D> null
);
=20
------=_Part_3893_2076755479.1485855813449--