Jump to:

23456 Posts in 18905 Topics by 2877 members

General Questions

SilverStripe Forums » General Questions » DateTime/datepicker format problems

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 2
Go to End
Author Topic: 2569 Views
  • kinglozzer
    Avatar
    Community Member
    139 Posts

    Re: DateTime/datepicker format problems Link to this post

    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

  • swaiba
    Avatar
    Forum Moderator
    1788 Posts

    Re: DateTime/datepicker format problems Link to this post

    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/

  • Romano
    Avatar
    Community Member
    13 Posts

    Re: DateTime/datepicker format problems Link to this post

    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');

  • martimiz
    Avatar
    Forum Moderator
    1078 Posts

    Re: DateTime/datepicker format problems Link to this post

    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

  • tonibecker
    Avatar
    Community Member
    6 Posts

    Re: DateTime/datepicker format problems Link to this post

    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?

  • Futureweb
    Avatar
    Community Member
    232 Posts

    Re: DateTime/datepicker format problems Link to this post

    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;      
    }

  • Liam
    Avatar
    Community Member
    470 Posts

    Re: DateTime/datepicker format problems Link to this post

    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');

    2569 Views
Page: 1 2
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.