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

DataObjectManage DataPickerField change display format


Go to End


4 Posts   819 Views

Avatar
Mackodlak

Community Member, 95 Posts

19 September 2011 at 7:52pm

Hey,

I have some problems with displaying the date picked out in DataPickerField. Can som1 point me to API or sth?
I have been able to switch the backend display form with adding DatePickerField::set_date_format('dd-mm-yyyy'); to _config.php but using $Datum (croatian for $Date - name of the variable) in template ALWAYS returns date in yyyy-mm-dd format.
I need it to be dd-mm-yyyy or even better dd.mm.yyyy. How to accomplish this?

Thank you!

Avatar
UncleCheese

Forum Moderator, 4102 Posts

20 September 2011 at 8:18am

There are many functions available for date formatting. See sapphire/core/model/fieldtypes/Date.php

$Datum.Nice
$Datum.Format(d-m-Y) etc..

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

Avatar
Mackodlak

Community Member, 95 Posts

20 September 2011 at 6:53pm

Edited: 20/09/2011 11:24pm

Yeah, I have tried that be4 posting and it didn't work for some reason...
Either I didn't do ?flush=1 or I had a typo....
I tried it now again and it works... seems so silly now...
Thank you anyways!

I have one more silly question... How do I put todays date into a calendar and check if date from datepicker is equal or greater than today?
st like return $this->Datum>=$today; ?

EDIT:
figured it out myself.
don't know if it is the best solution, but it did it as follows:

in template I check the function <% if isOver %> , and in .php the function looks like:

public function isOver(){
$Date = SS_Datetime::now();
return ($this->Datum<$Date->value);
}

Just in case som1 else is wondering the same thing

Avatar
UncleCheese

Forum Moderator, 4102 Posts

21 September 2011 at 1:30am

$Datum.InFuture