Caution: This documentation is for eZ Publish legacy, from version 3.x to 6.x.
For 5.x documentation covering Platform see eZ Documentation Center, for difference between legacy and Platform see 5.x Architecture overview.

datetime

Summary

Formats dates/times according to settings in "datetime.ini".

Usage

{input|datetime( preset_format [, format ] )}

Parameters

NameTypeDescriptionRequired
preset_format string Preset datetime format set in "datetime.ini". Yes.
format string Custom format (when preset format is set to "custom"). No.

Returns

A string representation of the input parameter.

Description

This operator takes care of formatting dates and times according to the setting defined in "datetime.ini" (or a configuration override). In addition, the operator also allows custom formats when the "preset_format" parameter is set to "custom". A custom format must be specified using the "format" parameter. The following table reveals the different elements that can be used in a custom format.

Element

Output

Description

%a

am

Lowercase Ante meridiem and Post meridiem.

%A

AM

Uppercase Ante meridiem and Post meridiem.

%d

08

Day of the month, 2 digits with leading zeros.

%D

Wed

A short textual representation of a day, in accordance with the "[ShortDayNames]" section of the language .INI file located in the "share/locale" directory.

%F

October

A full textual representation of a month, such as January or March.

%g

12

12-hour format of an hour without leading zeros.

%G

0

24-hour format of an hour without leading zeros.

%h

12

12-hour format of an hour with leading zeros.

%H

00

24-hour format of an hour with leading zeros.

%i

00

Minutes with leading zeros

%j

8

Day of the month without leading zeros

%l

Wednesday

A full textual representation of the day of the week.

%m

10

Numeric representation of a month, with leading zeros.

%M

Oct

A short textual representation of a month, in accordance with the "[ShortMonthNames]" section of the language .INI file located in the "share/locale" directory.

%n

10

Numeric representation of a month, without leading zeros.

%O

-0500

Difference to Greenwich time (GMT) in hours.

%s

00

Seconds, with leading zeros.

%T

CDT

Timezone setting of this machine.

%U

1065589200

Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT).

%w

3

Numeric representation of the day of the week.

%W

41

ISO-8601 week number of year, weeks starting on Monday.

%Y

2003

A full numeric representation of a year, 4 digits.

%y

03

A two digit representation of a year.

%z

280

The day of the year.

%Z

-18000

Timezone offset in seconds. The offset for timezones west of UTC is always negative, and for those east of UTC is always positive.

The date used to generate the contents of this table was "12:00 AM (Midnight) CDT on October 8, 2003".

Examples

Example 1

{currentdate()|datetime( 'mydate' )}

The following output will be produced: "13:15 6 Feb 2004" (according to the configuration settings).

Example 2

{currentdate()|datetime( 'custom', '%h:%i %a %d %F %Y' )}

The following output will be produced: "01:15 pm 06 February 2004" (custom format).

Balazs Halasy (05/02/2004 10:35 am)

Svitlana Shatokhina (09/02/2006 8:02 am)


Comments

  • full list of custom formats

    It seems that "custom" format strings are passed directly to php date() function. Therefore the list above is not complete, for complete list look at php documentation:
    http://php.net/date
  • datetime(custom,"%M") not always 3 letters

    At least when using Nowegian language some moths with short names gets out with full name.
    In norwegian 'April', 'Mars', 'Juni' and 'July' is displayed in its full form.
    If you need it to only display 2 letters like this doc says it does, take a look at
    http://ez.no/doc/ez_publish/techn...plate_operators/strings/extract_left
    • Re: datetime(custom,"%M") not always 3 letters

      3 letters, not 2.
  • Examples needed,

    Please can you giive us more than two examples.
  • selecting different locale

    Is it possible to have date and time output in a different locale than the one set for the siteaccess?