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

DateTime/datepicker format problems


Reply

15 Posts   2639 Views

Avatar
kinglozzer

17 March 2012 at 12:33am Community Member, 146 Posts

That obviously suggests that it's a problem specific to the beta, but I couldn't find anything to suggest that the DateField class has been altered at all.

Is the beta using a different version of JQuery or anything? I'm starting to think that it might be a javascript issue

Avatar
swaiba

17 March 2012 at 11:39pm Forum Moderator, 1796 Posts

I've not started to use SS3 yet, your best bet is to ask on the dev list..

https://groups.google.com/forum/?fromgroups#!forum/silverstripe-dev

or raise a bug on...

http://open.silverstripe.org/

Avatar
Romano

19 March 2012 at 4:18am Community Member, 13 Posts

SilverStripe v2.4

Need to change the date formatting mask. This solution is for many languages.

1. Open file "sappire\core\model\fieldtypes\Date.php"
2. Replace function "date" and formatting mask with strftime function (see more http://www.php.net/manual/en/function.strftime.php)
3. Open your "_config.php" file and add this string: setlocale(LC_TIME,'');   or   setlocale(LC_TIME, 'your_LOCAL');

Avatar
martimiz

3 July 2012 at 12:31am Forum Moderator, 1091 Posts

Hi,
I ran into this issue using version 3.0.0 stable, so I thought I'd share. Example: Dutch locale (nl):

first you set something like this in your getCMSFields()

...
$fields->addFieldToTab('Root.MyTab', $date = new DateField('Date', 'MyDate'));
...
$date->setConfig('showcalendar', true);
$date->setConfig('jslocale', 'nl');
$date->setConfig('dateformat','dd-MM-yyyy');

Next you need to have a regional file be present for the desired language. At the moment these are not (yet) included in the SilverStripe distribution. Get them here: http://jquery-ui.googlecode.com/svn/trunk/ui/i18n/

SilverStripe expects this file to live in /framework/thirdparty/jquery-ui/minified/i18n/jquery.ui.datepicker-nl.min.js (note the .min in the name)

Ticket here: http://open.silverstripe.org/ticket/7610

Martine

Avatar
tonibecker

6 July 2012 at 5:43pm Community Member, 6 Posts

Is it possible to show the datepicker in my gridfield?
I use it in my eventgrid and when i add new entry and jumping to the input mask picker is not working.
Some ideas how to solve this problem?

Avatar
Futureweb

18 October 2012 at 3:04pm Community Member, 233 Posts

Hi,

I just had similar issues - wrong date format swapping dates and months....
you have to turn set the datefeild config to show, and to use dd-MM-yyyy

<?php

class Event extends DataObject {

public static $db = array(      
    'Title' => 'Varchar',
    'Date' => 'Date',
    'Details' => 'HTMLText',
);

public function getCMSFields() {
   
      DateField::set_default_config('showcalendar', true);
      DateField::set_default_config('dateformat','dd-MM-yyyy');
      
      $fields = parent::getCMSFields();
      $fields->removeFieldFromTab("Root.Main","EventPageID");      
      
      return $fields;      
}

Avatar
Liam

19 October 2012 at 2:20pm Community Member, 470 Posts

My issue isn't the exact same, but it is an issue with the calendar picker.

If the calendar picker field is required, I'm finding when I pick the date with the jquery calendar, it fills the field in fine, but when I go to submit the form the JS validation says that the form is required and needs to be filled out.

Has anybody experienced this before? I've had clients tell me the same and I can replicate it.

I'm just using the userforms module, and setting the date in my config file as i18n::set_date_format('dd/MM/YYYY');