Posted by
ErichSteinboeck on 1209678349|%e %b %Y|agohover, last edited by
ErichSteinboeck on 1248292784|%e %b %Y at %H:%M |agohover
%%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%% | 1259357646|%e %b %Y, %H:%M %Z|agohover |
| %%date|On %e.%m.%Y at %H:%M:%S%% | 1238710779|On %e.%m.%Y at %H:%M:%S |
| %%date|%c|agohover%% | 1218889031|%c|agohover |
| %%date|the time of the post|agohover%% | 1206365348|the time of the post|agohover |
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.





