Posted by ErichSteinboeck on 1209678349|%e %b %Y|agohover, last edited by leiger on 1275120949|%e %b %Y at %H:%M |agohover
Tags: date date-format feed format frontforum listpages live template
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%% | 08 Feb 2012 15:01 |
| %%date|On %e.%m.%Y at %H:%M:%S%% | 07 Nov 2009 15:23 |
| %%date|%c|agohover%% | 20 Mar 2009 18:12 |
| %%date|the time of the post|agohover%% | 08 Aug 2008 06:11 |
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) | 1236600298|%a |
| %A | full weekday name | 1236600298|%A |
| %b | abbreviated month name (3 letters) | 1236600298|%b |
| %B | full month name | 1236600298|%B |
| %c | local date representation | 1236600298|%c |
| %d | day of the month (01…31) | 1236600298|%d |
| %D | is equivalent to “%m/%d/%y” | 1236600298|%D |
| %e | day of the month (1…9, 10…31) | 1236600298|%e |
| %H | hours (00…23) | 1236600298|%H |
| %I | hours (00…12) | 1236600298|%I |
| %m | month (01…12) | 1236600298|%m |
| %M | minutes (00…59) | 1236600298|%M |
| %O | nn seconds/minutes/hours/days | 1236600298|%O |
| %p | AM/PM | 1236600298|%p |
| %r | is equivalent to “%I:%M:%S %p” | 1236600298|%r |
| %R | is equivalent to “%H:%M” | 1236600298|%R |
| %S | seconds (00…59) | 1236600298|%S |
| %T | is equivalent to “%H:%M:%S” | 1236600298|%T |
| %y | year (00…99) | 1236600298|%y |
| %Y | year (1970…2999) | 1236600298|%Y |
| %z %Z |
time zone | 1236600298|%z |
The above list is exhaustive, no other %modifiers are recognized.
Links
- Module Feed documentation
- Module FrontForum documentation
- Module ListPages documentation
- “Live” templates documentation
- [[date ...]] documentation (which was copied from the Commmunity How-To Date: How Long Ago?)
Backlinks
Author
ErichSteinboeck. Please visit his/her userPage.
Other(!) HowTos posted by ErichSteinboeck
- Module Attributes via URL
- ListPages: Automatic Header
- Direct Links to Sub-Pages of System Pages
- Include Part Of A Page Only (Tricky Version)
- Set Up An Infobox
- Include Inline
- System Variables
- Set Up an Infobox — Exclude Specific Attributes
- Include With Defaults
- Page Count
- Create Sortable List of Pages
- Date: How Long Ago?
- Include a Forum Thread
- System Variables: Details
- Include Part Of A Page Only
- Iframe Link
- Nested Comments
- How Many Days Does Your Wiki Exist





