Is there a way to format the date in the results of a custom query? I have the date selected from the table as Date, but then in the control on the page where I'm using the query, $Date returns the date in a format I don't want on that page, and things like $Date.Nice and $Date.format(M) all return nothing.
We've moved the forum!
Please use forum.silverstripe.org for any new questions
(announcement).
The forum archive will stick around, but will be read only.
You can also use our Slack channel
or StackOverflow to ask for help.
Check out our community overview for more options to contribute.
- Page 11(current)
- 2
- Next 10 entries
$customQueryObj->Date = DBField::create('Date', $customQueryObj->Date);
I don't understand what you're trying to say. Where are you suggesting I put that?
Your custom query returns the date as a string. You will need to iterate the results of your query and reapply the date object to your date value before you return the data to the template.
Hi ya,
Not sure if this is what you're after,
when i've got a data object page and i've wanted to get the short month of a date so used
public function getMonth() {
return $this->obj('CalloutDate')->ShortMonth();
}
this then meant i could use $CalloutDate.ShortMonth on the template in the control.
you can do the same for nice.
Mick
Thanks for the suggestions. I'll look into this and see if I can get it working properly.
I experimented with this at length, couldn't get it to work, decided to leave it alone awhile, came back to it, still can't get it to work.
Useful Discussion
- Page 11(current)
- 2
- Next 10 entries