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.

General Questions

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

SS 3.1.0-beta2 and time values


3 Posts   304 Views


13 May 2013 at 3:12am Community Member, 35 Posts

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?


13 May 2013 at 8:17am Forum Moderator, 474 Posts

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


13 May 2013 at 9:06am (Last edited: 14 May 2013 3:00am), Community Member, 35 Posts

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:

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