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   1582 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, 4094 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