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
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%% | 25 Feb 2025 11:13 |
%%date|On %e.%m.%Y at %H:%M:%S%% | 09 Jan 2015 05:15 |
%%date|%c|agohover%% | 11 Jan 2010 11:45 |
%%date|the time of the post|agohover%% | 14 Jun 2009 23:35 |
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
- 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.
I have a live template that incorporates three dates as content blocks — startdate, enddate, and nextdate.
Startdate and enddate I've formatted as YYYY-MM-DD, and I pass these via url to a Pipe, which pulls feed items that occur between those two days.
So far, nextdate simply tells readers when to expect the next newsletter. From that standpoint, it could be any format — "June 9, 2010". But I could make it do more, so I'd like to format nextdate the same way, YYYY-MM-DD.
Is there some way to accept YYYY-MM-DD in a content block and to reformat it as %%content{n}|%A, %B %e%%?
It's impossible with a Wikidot-based solution. No idea about external solutions… someone else might have something in mind that could help.
There's a thread in the designs section that I'm thinking of but I can't quite find it with only a quick look… might have another look later.
There was a design spec about modifying things like this. For example (just making most of these up, though upper/lower case were definitely on the thread I'm thinking about):
~ Leiger - Wikidot Community Admin - Volunteer
Wikidot: Official Documentation | Wikidot Discord server | NEW: Wikiroo, backup tool (in development)
could you link to this template you've got somewhere? Do you remember the email-field solution I made… Maybe a solution for this problem can be found in the same way of working, but I would like to see the context in wich you are using this.
A - S I M P L E - P L A N by ARTiZEN a startingpoint for simple wikidot solutions.
Steven — same context we've discussed elsewhere: our newsletter.
Here's an example of the application
The YYYY-MM-DD format could be useful in calling feed items, but I'd like to be able to reformat it to Day, Month Date.