As if there weren’t enough date based plugins… this is something I needed for a client. Could be useful in the right situations.
{exp:wi_friendlee_date m="month" d="date" y="year" h="hours" mn="minutes" s="seconds" display="php date codes"}
Place this tag in your code and replace month date year hours minutes seconds parameters in the code with any information to have the plugin return the date formatted nicely.
Only m, d and y are required. If no h, mn or s parameters are supplied, the plugin will not add hours, minutes or seconds into the generated date/time.
You can control the display that is output by entering typical PHP date formatting codes into the display parameter. See http://us2.php.net/date for all available options.
The default display, if you don’t supply a display parameter is MM/DD/YYYY.
Examples:
{exp:wi_friendlee_date m="6" d="24" y="1995"}
Output: 06/24/1995
{exp:wi_friendlee_date m="6" d="24" y="1995" h="9" mn="55" s="00"}
Output: 06/24/1995 09:55:00
{exp:wi_friendlee_date m="6" d="24" y="1995" display="D, F jS, Y"}
Output: Sat, June 24th, 1995
{exp:wi_friendlee_date m="6" d="24" y="1995" h="9" mn="55" s="00" display="D, F jS, Y, g:i:s"}
Output: Sat, June 24th, 1995, 9:55:00
{exp:wi_friendlee_date m="{segment_4}" d="{segment_5}" y="{segment_6}" display="D, F jS, Y"}
URL: www.mydomain.com/template_group/template/url_title/6/24/1995/ Output: Sat, June 24th, 1995
Hi Chad,
There are at least two plugins having very similar functionality: Nice Date and Formatted Date.
Hey Chad,
I only wanted the month and year for my archive heading so I slightly modded your plugin. Basically I added some default options to the dat vars so mktime doesn’t break.
$m = $TMPL->fetch_param('m') ? $TMPL->fetch_param('m') : 1;
$d = $TMPL->fetch_param('d') ? $TMPL->fetch_param('d') : 1;
$y = $TMPL->fetch_param('y') ? $TMPL->fetch_param('y') : 0;
$h = $TMPL->fetch_param('h') ? $TMPL->fetch_param('h') : 0;
$mn = $TMPL->fetch_param('mn') ? $TMPL->fetch_param('mn') : 0;
$s = $TMPL->fetch_param('s') ? $TMPL->fetch_param('s') : 0;
$display = $TMPL->fetch_param('display');
Then I scrapped the warning. Now I can do cool stuff like:
There were no posts published in {exp:wi_friendlee_date m="{segment_4}" y="{segment_3}" display="F Y"}
Any idea if this plugin could be used in conjunction with the simple math plugin? (http://ellislab.com/forums/viewthread/110055/P36/#631282) I was trying to get a date calculated such as: I have a field (days) that has 10 (or 20 or ..) and I have a field for date such as 12/12/2009. I wanted to have the {date}+(days) output the result in a date format: 12/22/2009. is there a easy way to do such?
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.