Skip to main content
This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.
Hi all. I'm follow the Date Documentation here:
I have two dates, StartDate, and EndDate, and I see the cool method Range in the documentation.
$Expires.Range(date2) - You give a second date and it returns a condensed english Ã¢â‚¬Å“phraseÃ¢â‚¬Â for that date range. E.g. Ã¢â‚¬Å“12 - 18 JuneÃ¢â‚¬Â or Ã¢â‚¬Å“12 June - 23 AugustÃ¢â‚¬Â.
In my template, I am trying to use this method as follows:
This returns nothing. Despite both EndDate and Startdate displaying by themselves just fine. Any ideas?
Missing a $ in front of end date by any chance?
Sorry Will, I should have added that that was the first thing I tried. If I change the code to:
I get a parse error:
Parse error: syntax error, unexpected T_STRING, expecting ')' in C:\WINDOWS\Temp\silverstripe-cacheW--Viva_Expeditions-html\.cacheW..Viva_Expeditions.html.themes.vivaexp.templates.Tour.ss on line 344
Strange... maybe you cant pass variables into Range in the template. Might have to try somethin in a PHP method then I guess. As if your field EndDate and $EndDate dont work I dont know what else you could use!
Thanks for trying Will. The Documentation above specifically states:
The following $ variables can be used in the template. Replace Ã¢â‚¬Å“ExpiresÃ¢â‚¬Â with the name of your database field.
I have tried using range in a function on the page controller, but I get a 'non-object' error. May be a bug?