Content last modified Monday 6 March 2017
hop to #bottom
Categories:
Author:
Current version:
0.3
About It:
Get it:
Rate it:
  • Helpful?
  • 1 Yes
  • 0 No
Flag it:
Contact Reason [ ? ]

etc_date

Description

Textpattern has localized strings for almost everything, but dates are under servers responsibility. This is reasonable, since dates are more than just months/days names, but can be a problem if some locales are missing on the server.

This is where etc_date intervenes. It allows you to define your own date strings to display dates in the language of your choice. Moreover, you can use custom calendars, to transform 1799-11-09 into 18 Brumaire An VIII (though currently only Gregorian, Hijri and Jalali calendars are available).

Even if you do not need to localize dates, etc_date can come handy, since it understands expressions like today, next Friday, etc. Moreover, it includes <txp:etc_if_date /> and <txp:etc_date_diff /> tags, useful for dates comparison.

Usage

<txp:etc_date date="posted" calendar="hijri" lang="ar_AR" format="%d %B %Y" />
<txp:etc_if_date value="12-24..12-26" format="%m-%d">
	Merry Christmas!
</txp:etc_if_date>
<txp:etc_if_date date="expires" compare="now..+3 days" format="%s">
	This article expires in <txp:etc_date_diff from="yesterday" to="expires" /> days!
</txp:etc_if_date>
Article Request Count:
Keywords/tags:
Initially released:
2013-03-26
Posted here:
16 Jul 2013
Article modified:
20 Dec 2013

If there is a comment form at the Information URL, you may want to leave your comments/questions there or at the Forum thread for quicker feedback. Otherwise, comment away:

Your comment will NOT be submitted until you click the 'Submit' button on the next pageload.

Subscribe to this article's comments RSS feed. [ ? ]   View Recent Comments across the site.

You know you want to visit the Archives.

Browse

Categories


Articles

There are also tag clouds, 'cause those are fun.
Published with Textpattern