Jump to:

7940 Posts in 1543 Topics by 946 members

DataObjectManager Module

SilverStripe Forums » DataObjectManager Module » DataObjectManage DataPickerField change display format

Discuss the DataObjectManager module, and the related ImageGallery module.

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

Page: 1
Go to End
Author Topic: 470 Views
  • Mackodlak
    Avatar
    Community Member
    95 Posts

    DataObjectManage DataPickerField change display format Link to this post

    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!

  • UncleCheese
    Avatar
    4085 Posts

    Re: DataObjectManage DataPickerField change display format Link to this post

    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

  • Mackodlak
    Avatar
    Community Member
    95 Posts

    Re: DataObjectManage DataPickerField change display format Link to this post

    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

  • UncleCheese
    Avatar
    4085 Posts

    Re: DataObjectManage DataPickerField change display format Link to this post

    $Datum.InFuture

    470 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.