Content last modified Tuesday 24 August 2021
hop to #bottom
Categories:
Author:
Current version:
0.3
About It:
Get it:
Rate it:
  • Helpful?
  • 1 Yes
  • 0 No
Flag it:

If you'd like to provide updated information and do not have access to directly edit, please contact the site admin; thanks!

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

You know you want to visit the Archives.
Published with Textpattern