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.

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.

DataObjectManager Module /

Discuss the DataObjectManager module, and the related ImageGallery module.

Moderators: martimiz, UncleCheese, Sean, Ed, biapar, Willr, Ingo, swaiba

How do I format the Date in DOM?


Go to End


2 Posts   2031 Views

Avatar
otherjohn

Community Member, 125 Posts

7 October 2010 at 2:34am

Hi all,
As you can tell from my numinous post, I fumble around a lot here. Please forgive me in the abundance of my dumb questions.

I have a date field in the DOM table but it always shows the date like "2010-10-05", how can I format to something else?

Thanks!

Avatar
UncleCheese

Forum Moderator, 4102 Posts

7 October 2010 at 12:24pm

Easiest thing to do is create a custom getter..

public function getFormattedDate() {
return $this->obj('YourDateField')->Format('m-d-Y');
}

Then in your headings array, just use:

'FormattedDate' => 'Your date heading'

---------------
Silverstripe tips, tutorials, screencasts, and more. http://www.leftandmain.com