Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Re: Outputting current date
Wow! Excellent! Was this something you’d tried before or did you concoct this just now? Either way, in very brief testing for now it works as advertised. Big thanks!!
Other time-related functionality I can think of is:
- compare against some specified time so that one can display something related to a particular time, e.g. “show from__” or “show until __”.
- formatting from->to dates. I currently have a custom solution for this, but what makes it tricky is finding a simple way to define attributes for the various combinations across time unit boundaries, e.g. 3 – 6 April 2024, 31 March – 2 April 2024, 25 December 2023 – 6 January 2024, etc. In German, I typically have two variants: one verbose as described and one concise with the 03. – 06.04.24, 31.03. – 02.04.24, 25.12.23 – 06.01.24, so I have these hard-coded in my own version.
Whether or not these pass the “bloatware” test ;-) I’m happy to have this new tag in our tool belt. Thank you.
TXP Builders – finely-crafted code, design and txp
Offline
Re: Outputting current date
Date ranges are an absolute mare. And virtually impossible to code across languages in a meaningful way.
I’ve got a delivery date range Shortcode for a client, and the Form that outputs that one line is about 175 lines of PHP.
The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.
Txp Builders – finely-crafted code, design and Txp
Online
Re: Outputting current date
Bloke wrote #336998:
Date ranges are an absolute mare. And virtually impossible to code across languages in a meaningful way.
I’ve got a delivery date range Shortcode for a client, and the Form that outputs that one line is about 175 lines of PHP.
Wow. Mine is obviously a lot simpler. This mini plugin is what I use for my own use.
TXP Builders – finely-crafted code, design and txp
Offline
Re: Outputting current date
Yeah, this one takes all bank holidays into account, and has to skip them to work out the next available delivery dates after that. It’s a monster.
The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.
Txp Builders – finely-crafted code, design and Txp
Online
Re: Outputting current date
jakob wrote #336996:
Wow! Excellent! Was this something you’d tried before or did you concoct this just now? Either way, in very brief testing for now it works as advertised. Big thanks!!
Basically, just renamed posted()
function, a five minutes work :-)
Other time-related functionality I can think of is:
- compare against some specified time so that one can display something related to a particular time, e.g. “show from__” or “show until __”.
- formatting from->to dates. I currently have a custom solution for this, but what makes it tricky is finding a simple way to define attributes for the various combinations across time unit boundaries, e.g. 3 – 6 April 2024, 31 March – 2 April 2024, 25 December 2023 – 6 January 2024, etc. In German, I typically have two variants: one verbose as described and one concise with the 03. – 06.04.24, 31.03. – 02.04.24, 25.12.23 – 06.01.24, so I have these hard-coded in my own version.
Comparing against a given range(s) is doable (IIRC etc_date
does it). As for from->to
output, for a given language it looks as easy as two <txp:date />
combination (with different format
). But, as Stef says, a universally valid output in different languages/calendars looks tricky.
Offline
Re: Outputting current date
etc wrote #336992:
I’ve just added
<txp:date />
tag to dev, please test and suggest feature ideas. Currently it works e.g. like this:
<txp:date gmt time="now" lang="de" calendar="hebrew" format="%Y %b" />...
Lovely… Works great so far! Thanks you.
(bye bye another PHP snippet)
Where is that emoji for a solar powered submarine when you need it ?
Sand space – admin theme for Textpattern
Offline