datetime
Summary
Formats dates/times according to settings in "datetime.ini".Usage
{input|datetime( preset_format [, format ] )}
Parameters
Name | Type | Description | Required |
---|---|---|---|
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