Jump to:

22976 Posts in 11702 Topics by 2826 members

General Questions

SilverStripe Forums » General Questions » SS 3.1.0-beta2 and time values

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

Page: 1
Go to End
Author Topic: 230 Views
  • ImacSS
    Avatar
    Community Member
    35 Posts

    SS 3.1.0-beta2 and time values Link to this post

    Having a problem getting the CMS to store time values in the 'PM' range. I've tried using both a 'Time' data type with 'TimeField' form field, and a 'SS_Datetime' data type with a 'DatetimeField' form field - and both setups store entries of '21:00' or '9:00 PM' as '9:00 AM'.

    Is there some configuration setting I am missing here, or is this a known bug with beta2?

  • simon_w
    Avatar
    Forum Moderator
    467 Posts

    Re: SS 3.1.0-beta2 and time values Link to this post

    Have you tried beta3 to see if you still have the problem?

  • ImacSS
    Avatar
    Community Member
    35 Posts

    Re: SS 3.1.0-beta2 and time values Link to this post

    Edited to simplify code example

    Well, after migrating everything over to beta3, I'd say the problem still exists.

    Here's how I have things setup:

    Event.php
    (NOTE: This is inherited from GalleryObject.php as I have onAfterWrite methods that apply to a number of classes.
    The 'BeginDT' and 'EndingDT' fields I added to see if using the SS_Datetime fields would make a difference.

    class Event extends GalleryObject {
       
       private static $db = array(
          'Name' => 'Varchar(75)',
          'Description' => 'Text',
          'StartDate' => 'Date',
          'EndDate' => 'Date',
          'StartTime' => 'Time',
          'EndTime' => 'Time'
       );

       public function getCMSFields() {
          $fields = parent::getCMSFields();

          // ...

          $startDate = new DateField('StartDate', 'Starting Date');
          $startDate->setConfig('showcalendar', true);
          $fields->addFieldToTab('Root.Main', $startDate);

          $endingDate = new DateField('EndDate', 'Ending Date');
          $endingDate->setConfig('showcalendar', true);
          $fields->addFieldToTab('Root.Main', $endingDate);

    // When 'PM' values are entered into these fields, they get converted to 'AM' once saved
          $fields->addFieldToTab('Root.Main', new TimeField('StartTime', 'Starting Time'));
          $fields->addFieldToTab('Root.Main', new TimeField('EndTime', 'Ending Time'));

          return $fields;
       }
    }

    There is an EventAdmin.php file which extends ModelAdmin to manage Event entries, which is setup to only manage Event objects.

    Is there something ridiculous I'm doing here?

    Regardless of what 'PM' type value I put into either StartTime, EndTime, or the time fields of BeginDT or EndingDT - the CMS ignores these values and stores the times as the 'AM' equivelant.

    230 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.