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've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

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

DateTime/datepicker format problems


Go to End


15 Posts   6498 Views

Avatar
kinglozzer

Community Member, 187 Posts

17 March 2012 at 12:33am

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

Forum Moderator, 1899 Posts

17 March 2012 at 11:39pm

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

Community Member, 13 Posts

19 March 2012 at 4:18am

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

Forum Moderator, 1391 Posts

3 July 2012 at 12:31am

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

Community Member, 6 Posts

6 July 2012 at 5:43pm

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
JonShutt

Community Member, 244 Posts

18 October 2012 at 3:04pm

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

Community Member, 470 Posts

19 October 2012 at 2:20pm

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

Go to Top