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're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

General Questions /

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

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

DateTimeField, Invalid time format

Go to End

10 Posts   5923 Views


Community Member, 541 Posts

20 April 2010 at 9:26am

Hi All,

I have been having a lot of issues with the datetimefield in 2.4. Basically, the popup calendar seems to enter the date in the wrong format (IE: DD/MM/YYYY, rather than MM/DD/YYY).

Is there a way of configuring the format that silverstripe expects for this field? Or is this a Bug?




Community Member, 541 Posts

20 April 2010 at 11:41am

Cool, that seems to work. Thanks Luke!

Quick question, do you know if its possible to set $dateField->getDateField()->setConfig('dateformat', 'dd/MM/YYYY'); as the default for all versions of DateTimeField?

Maybe overriding a static in the class?




Community Member, 18 Posts

22 April 2010 at 10:41am

Is it possible to do something like this with CalendarDateField? I'm digging through the sapphire folder to see what methods are available for DateField, but can't find anything like setConfig().



Forum Moderator, 801 Posts

11 May 2010 at 9:01pm

I've opened a ticket for this here:

Basically, we need to configure the javascript calendar library according to the date format settings in PHP.
Unfortunately Zend_Date doesnt allow a more "forgiving" validation for date strings, so we have to ensure the js passes in the right format. I agree that "5 May 2010" is a bit of a weird default, thats the Unicode "date medium" setting for en_US...

The date/time format confusion will also be less common once we implement this guy here:

Suggestions welcome, its a tricky problem...


Community Member, 114 Posts

13 May 2010 at 6:11am

I ended up using DatePickerField from dataobjectmanager and modified a line of code to change that datepicker to US -style dates.


Community Member, 541 Posts

3 June 2010 at 10:23pm

Could you add a "TimeZone" dropdown next to the field. By default it would be filled in with one (say, us/uk etc), but then it could be changed?

Alternatively, you could maybe have a static in the DatetimeField class, something like:

DatetimeField::$timezone = "dd/mm/yyyy";

Just some thoughts?



Forum Moderator, 801 Posts

4 June 2010 at 9:00am

Timezone support would be great, although we'd have to investigate how its storage works across databases.
Tom has done some timezone extensions to the CMS, incl. a TZDateTimeField: - its pre 2.4 stable, not sure how useful it still is.

Do you guys still see this as part of the DateField codebase? I want to avoid ending up with a huge bloated class (think HasManyComplexTableField), any suggestions on how to apply this cleanly in terms of design patterns?

Zend_Date already has good timezone conversion support, so making this a presentational setting (and storing the date without timezone) might be a lot simpler.

By the way, I've added a patch to the datepicker ticket mentioned before - it works with jQuery UI now, wohoo :) Still looking for feedback and code review:


Community Member, 6 Posts

1 September 2010 at 10:52pm

Do you get this working if you empty browser cache completely?
My calendar dosnt popup when i go to date field in cms. If i refresh browser then its ok, and after that it load ok.

Same thing happens with Dataobjectmanager module. First load dosnt seem to load correctly like something were missing, but after refreshing all ok.

My code looks like this.
class MyPage extends Page {
static $db = array (
'MyPageName' => 'Text',
'From' => 'Date',
'To' => 'Date'

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

// add fields
$datefieldFrom = new DateField('From','From');
$datefieldTo = new DateField('To','To');
$datefieldFrom->setConfig('showcalendar', true);
$datefieldTo->setConfig('showcalendar', true);

$f->addFieldToTab("Root.Content.Main", $datefieldFrom);
$f->addFieldToTab("Root.Content.Main", $datefieldTo);

return $f;

I been banging my head against wall with this one pretty long....

Go to Top