Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
EE1 & 2 addon for friendly date formating
PHP
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
ee1
ee2/jb_friendly
README.textile

README.textile

This is a simple plugin for relative time periods for Expression Engine 1.x and 2.×.
Basic usage

My prefered tag usage goes like so:

{exp:jb_friendly entry_date="{entry_date}"} This entry was posted {friendly} {direction} {/exp:jb_friendly}

That will generate the date in a friendly format (including handling future/past dates) and wrap the full date in the abbreviation, since (or until) now, and the datetime provided.

If you’d like to do the friendly date between a different period just supply the tag like so:

{exp:jb_friendly entry_date=“{comment_date}” relative_date="{entry_date}"} This comment was posted {friendly} after the article {/exp:jb_friendly}

Parameters

* Entry Date entry_date=“123457890” *required The only required tag. The date you want the time since/until. If none is supplied, the plugin will bail out and return an empty string. Supplied unformated. * Relative Date relative_date=“123457890” detaults to now Optionally calculate the period between the entry date and another time. If none is supplied the system will calulate the period between now and the entry_date. * Stop After stop_after=“1 month” defaults to “never” Because of the wordy nature of the formatting, periods progressivly loose there accuracy the larger they get. Using this tag you can stop the dates turning into words after a set length. The valid options are : o stop_after=“1 day” o stop_after=“1 week” o stop_after=“1 month” o stop_after=“1 year” When the period is older than that, the tag friendly will naturally become the full date, formated. (Using the default date formatting style, modifyable via the date_format tag (see next)) If no stop_after param is supplied, the plugin will keep generating wordy periods for all dates. * Default Full Date Format format=”%d/%m/%y” defaults to “%F %d%S, %Y” Optionally alter the standard date_format. The default is returns in the form “August 19th, 2010”. Uses the exact same date formatting tags as every other date formatting tag.

Tags

* {friendly} The date period in friendly words. (English only at the moment). * {direction} If the time period is in the past, returns “ago”. If it is in the future “to go”. If the time period is longer than the stop_after paramter supplied, the {direction} will return nothing. * {full_date} The entry_date tag in full formated style. ie. “August 19th, 2010”

Support

If you have an issue with this plugin, support is handled either via github : http://github.com/joelbradbury/jb.friendly.ee_addon
or the author’s site : http://joelbradbury.net/code/friendly
Changelog

1.1
Added handling of RFC formatted dates
1.0
First Public Release

Something went wrong with that request. Please try again.