Hello all,
I’ve just knocked together a simple plugin which acts as a wrapper for the PHP date_modify function.
You just need to supply the plugin with the date you wish to modify (in YYYY-MM-DD format), the modification you want to make (“+1 day”, “next Tuesday”, anything that the PHP strtotime function understands), and an optional “return format” string.
An example may help:
<!-- EE Code -->
{exp:sl_datemodify date="2008-01-31" change_by="+1 day" return_format="jS M, Y"}
<!-- Output -->
1st February, 2008
I hope someone finds it useful.
Cheers, Stephen
Hi Stephen,
Hmm I think I must be the Bionic Man or something and people have me lo-jacked or something as I was just looking at this exact function today in the PHP manual!!
Actually I was looking at quite a few but it stuck in my mind as I was thinking “What exactly could I use this for?”.
Do you have any examples you could give as to where this would be useful inside of EE? I’m thinking perhaps some kind of diary usage or calendar or something along those lines.
Anyway will download and have a play. Looks like it will definitely be a useful one so thanks for that.
Best wishes,
Mark
Hi Mark,
Do you have any examples you could give as to where this would be useful inside of EE? I’m thinking perhaps some kind of diary usage or calendar or something along those lines.
I created it specifically because of the hCalendar microformat, as it happens. Here’s an example…
<div class="vevent">
<span class="summary">Web 2.0 Conference</span>:
<abbr title="2007-10-05">October 5</abbr>-
<abbr title="2007-10-20">19</abbr>
, at the <span class="location">Big Hotel, Cardiff, UK</span>
</div>
As you can see, the event ends on the 19th October, but the “encoded” date (in the abbr title) reads 20th October.
Bet you wish you hadn’t asked now.
Cheers, Stephen
As you can see, the event ends on the 19th October, but the “encoded” date (in the abbr title) reads 20th October. Bet you wish you hadn’t asked now. Cheers, Stephen
Hmm well I’m glad I asked but just a little confused really! Why would you have the date title set to the 20th?
Best wishes,
Mark
Hmm well I’m glad I asked but just a little confused really! Why would you have the date title set to the 20th?
Well, as you asked… this note on the hCalendar microformat page explains it:
Note 5: The difference between the DTEND ISO8601 date (2005-10-08) and the human readable date (7) is NOT a mistake. DTEND is exclusive, meaning, that the event ends just before the DTEND. Thus for events which start on one day and end on another day, the DTEND date must be specified as the day after the day that a human would say is the last day of the event.
It sort of makes sense if you stare at it long enough.
Cheers, Stephen
Well, as you asked… this note on the hCalendar microformat page explains it:Note 5: The difference between the DTEND ISO8601 date (2005-10-08) and the human readable date (7) is NOT a mistake. DTEND is exclusive, meaning, that the event ends just before the DTEND. Thus for events which start on one day and end on another day, the DTEND date must be specified as the day after the day that a human would say is the last day of the event.It sort of makes sense if you stare at it long enough. Cheers, Stephen
Okay now I have a headache!! 😊
Thanks for the explanation though…
…I think!
Best wishes,
Mark
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.