Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Pages: 1
#1 2007-03-04 15:31:36
- Vitruvius
- Plugin Author
- Registered: 2004-09-21
- Posts: 125
[plugin] [ORPHAN] srh_days_since
Introduction
This is yet another php hack — so if the code is ugly — please let me know.
In answer to this post a long time ago, I have cobbled together this plugin to return the number of days since (or to if it’s in the future) a date.
Usage
<txp:srh_days_since date="30 January 2006" nodiff="zero" />
returns something like “456 days”.
variables:
- date=”“ The plugin uses strtotime() which should accept common date formats like above. I have not tested others. The date can be in the future or the past.
- nodiff=”“ This is the text which will be displayed if there are no days between the specified date and current date. Default is ‘no’.
Possibilities
- If I get around to it (and I think I will ‘cause a client wants it) I’ll add the ability to specify the word displayed after the number of days. Currently it defaults to ‘days’ (or ‘day’ if there is only one day difference)
- It would be relatively straight forward to change the units to something a bit more wild (like seconds).
Offline
Re: [plugin] [ORPHAN] srh_days_since
If you replace "days" with gTxt('days') and "day" with gTxt('day'), the language chosen in textpattern will be used automatically, reducing the need for an extra attribute to provide the translation.
Offline
Re: [plugin] [ORPHAN] srh_days_since
What about fha_time_diff? Isn’t that the same thing?
Offline
#4 2007-03-04 20:45:51
- Vitruvius
- Plugin Author
- Registered: 2004-09-21
- Posts: 125
Re: [plugin] [ORPHAN] srh_days_since
ruud wrote:
If you replace
"days"withgTxt('days')and"day"withgTxt('day'), the language chosen in textpattern will be used automatically, reducing the need for an extra attribute to provide the translation.
Thanks for the tip – will do that shortly.
ragger wrote:
What about fha_time_diff? Isn’t that the same thing?
fha_time_diff is a far more powerful plugin – but the one thing it does not do is display only the number of days since a date. It returns time in proper units like: ’1 year 3 months and 14 days’, where as srh_days_since would return simply ’468 days’… There was a request for the pure ‘days only’ feature some time ago.
SH
Offline
Pages: 1