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

: date date-format feed format frontforum listpages live template

rating: +14

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%%

07 Jul 2025 20:56

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

31 Jan 2015 23:21

%%date|%c|agohover%%

19 Jan 2010 23:25

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

22 Jun 2009 19:49

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

ErichSteinboeck ErichSteinboeck . Please visit his/her userPage.


Related articles

Comments

date formatting for content blocks?
scottplan scottplan 05 Jun 2010 13:16

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%%?

by scottplan scottplan , 05 Jun 2010 13:16
Re: date formatting for content blocks?
leiger leiger 05 Jun 2010 15:40

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):

%%variable|to_uppercase%%
%%variable|to_lowercase%%
%%variable|to_link_format%%
%%variable|custom_date_format%%

~ Leiger - Wikidot Community Admin - Volunteer
Wikidot: Official Documentation | Wikidot Discord server

by leiger leiger , 05 Jun 2010 15:40
Re: date formatting for content blocks?

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.

by Steven Heynderickx Steven Heynderickx , 06 Jun 2010 10:28
Re: date formatting for content blocks?
scottplan scottplan 11 Jun 2010 14:43

Steven — same context we've discussed elsewhere: our newsletter.

Here's an example of the application

We'll post it on %%content{7}%%

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.

Last edited on 11 Jun 2010 14:59 by scottplan
by scottplan scottplan , 11 Jun 2010 14:43
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-Share Alike 2.5 License.
Click here to edit contents of this page.
Click here to toggle editing of individual sections of the page (if possible). Watch headings for an "edit" link when available.
Append content without editing the whole page source.
Check out how this page has evolved in the past.
If you want to discuss contents of this page - this is the easiest way to do it.
View and manage file attachments for this page.
A few useful tools to manage this Site.
Change the name (also URL address, possibly the category) of the page.
View wiki source for this page without editing.
View/set parent page (used for creating breadcrumbs and structured layout).
Notify administrators if there is objectionable content in this page.
Something does not work as expected? Find out what you can do.
General Wikidot.com documentation and help section.
Wikidot.com Terms of Service - what you can, what you should not etc.
Wikidot.com Privacy Policy.

AltStyle によって変換されたページ (->オリジナル) /