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.

DataObjectManager Module

Discuss the DataObjectManager module, and the related ImageGallery module.

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

How do I format the Date in DOM?


Reply

2 Posts   1555 Views

Avatar
otherjohn

7 October 2010 at 2:34am Community Member, 125 Posts

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

7 October 2010 at 12:24pm 4085 Posts

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