Feed/FrontForum/ListPages/live template — %%date%%

Posted by ErichSteinboeck on 01 May 2008 21:45, last edited by leiger on 29 May 2010 08:15

Tags: date date-format feed format frontforum listpages live template

rating: +14+x

Please note that %%date%% and %%date_edited%% are no longer recommended and should be replaced by
%%created_at%% and %%updated_at%%, respectively.

If you'd like to show the date of the most recent comment, you can use the new variable %%commented_at%%.

%%date%% Variable and format Parameter

Modules Feed, FrontForum, ListPages, and “live” templates support an optional format parameter for the custom-format %%date%% variable. Module ListPages, and “live” templates also support this optional format parameter for the custom-format %%date_edited%% variable.

In addition, also the [[date …]] tag makes use of the %modifiers documented here.

The documentation for module Feed, module FrontForum, module ListPages, and “live” templates states that the %%date%% (or %%date_edited%%) format parameter prints the “date with a custom format. Most tokens from php's strftime are accepted”.

In this How-To you'll find a full documentation for the %%date%% (and %%date_edited%%) variable.

Syntax

The syntax for the %%date%% and %%date_edited%% variable is

%%date<|<format><|agohover>>%%
%%date_edited<|<format><|agohover>>%%

where

  • < … > denote optional parameters
  • |” must be typed as is, with no blank between %%date and “|
  • format is an arbitrary text string that may include %modifiers, which are replaced by an actual (part of the) date or time. If not specified, format defaults to “%e %b %Y, %H:%M %Z”
  • agohover when specified displays a “hovering” text when the mouse is moved over any part of the displayed format string. The hovering text — “nn seconds/minutes/hours/days ago” — is, except for a trailing “ ago”, identical to the %O modifier explained below.

Examples

Here are some examples how to use %%date%%:

What you type … What you get …
%%date%%

23 Dec 2023 13:55

%%date|On %e.%m.%Y at %H:%M:%S%%

18 Aug 2014 07:27

%%date|%c|agohover%%

06 Jan 2010 10:39

%%date|the time of the post|agohover%%

23 May 2009 05:18

Note: Try moving the mouse over the last two examples to view the “hovering” text.

%Modifiers

The following %modifiers can be used within the format parameter:
Modifier Description Example
%a abbreviated weekday name (3 letters) 09 Mar 2009 12:04
%A full weekday name 09 Mar 2009 12:04
%b abbreviated month name (3 letters) 09 Mar 2009 12:04
%B full month name 09 Mar 2009 12:04
%c local date representation 09 Mar 2009 12:04
%d day of the month (01…31) 09 Mar 2009 12:04
%D is equivalent to “%m/%d/%y” 09 Mar 2009 12:04
%e day of the month (1…9, 10…31) 09 Mar 2009 12:04
%H hours (00…23) 09 Mar 2009 12:04
%I hours (00…12) 09 Mar 2009 12:04
%m month (01…12) 09 Mar 2009 12:04
%M minutes (00…59) 09 Mar 2009 12:04
%O nn seconds/minutes/hours/days 09 Mar 2009 12:04
%p AM/PM 09 Mar 2009 12:04
%r is equivalent to “%I:%M:%S %p” 09 Mar 2009 12:04
%R is equivalent to “%H:%M” 09 Mar 2009 12:04
%S seconds (00…59) 09 Mar 2009 12:04
%T is equivalent to “%H:%M:%S” 09 Mar 2009 12:04
%y year (00…99) 09 Mar 2009 12:04
%Y year (1970…2999) 09 Mar 2009 12:04
%z
%Z
time zone 09 Mar 2009 12:04

The above list is exhaustive, no other %modifiers are recognized.

Links

Backlinks

Author

ErichSteinboeckErichSteinboeck. Please visit his/her userPage.


Related articles

Comments

Add a New Comment
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-Share Alike 2.5 License.