Error message when using custom date format for events
Hello community. I hope that someone can give me some help here.
I have a TypoLight 2.7 installation, and single date events (start date only, or same start and end dates) works fine.
However, as soon as a end date is specified to make it a 2 or more day event, I get this error:
Code:
Warning: date_format() expects parameter 1 to be DateTime, boolean given in /home/brtorg/public_html/templates/event_default.tpl on line 6
I also know some of the reason behind it. I have customised the template to change the date format to d F Y, because the Typolight default wasn't very user friendly.
So I changed the template from
Code:
<p class="info"><?php echo $this->date; ?></p>
to this
Code:
<p class="info"><?php echo date_format(date_create($this->date), "d F Y") ?></p>
Now the question. Is there any way I can make this work for the d F Y format so that I can display a date range? Or is this an issue with the 2.7 version of TL, and would I need to update?
Thanks for any answers!
Re: Error message when using custom date format for events
Can you not simply set the format you require in Settings::Date Format/Time Format/Date and Time Format?
(this can also be set in each Website Root Page in Site Structure)
In this case you would need to revert your template back.
Re: Error message when using custom date format for events
Something like this came up in the old forums (heck, I may even have asked it).
In the settings module, dates seem to need to be in a numeric-only format. So any textual representation of a date entered into settings will throw an error. Nobody seemed to know why, but theorized it might have something to do with storing dates in the database.
However, you can also enter a custom date format in your "Site Root" (ideally, your site should have at least one page of type "Site Root", and all other pages should be a child of a "Site Root"). The date format in the Site Root will override what's in settings, and apparently accepts any format you want.
So I would try this first and see if it fixes your issue.
Re: Error message when using custom date format for events
Good to know Medianomaly - strange that one does and one doesn't.
I wonder if Leo realises this.
Maybe ones more for backend, the other for frontend output???
Re: Error message when using custom date format for events
Quote:
Originally Posted by Medianomaly
However, you can also enter a custom date format in your "Site Root" (ideally, your site should have at least one page of type "Site Root", and all other pages should be a child of a "Site Root"). The date format in the Site Root will override what's in settings, and apparently accepts any format you want.
Thanks, Medianomaly. That was exactly what I was looking for. All the best.