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.

All other Modules /

Discuss all other Modules here.

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

UserForms Date Format


Go to End


6 Posts   1712 Views

Avatar
edwardlewis

Community Member, 33 Posts

8 October 2011 at 2:20am

I have been searching through the code and I cant find anywhere to change the format of the date field. Is it possible to change it from:

MM/DD/YYYY

to

DD/MM/YYYY

Can someone point me in the right direction? Does it need to be set in mysite/_config.php or does it require editing some code in the module?

Thanks in advance!

Avatar
Willr

Forum Moderator, 5523 Posts

10 October 2011 at 9:19am

Looking at the code (https://github.com/silverstripe/silverstripe-userforms/blob/master/code/editor/EditableDateField.php#L48) it uses the default set to your i18n settings.

You could try setting your i18n date format via your mysite/_config.php - i18n::set_date_format('dd/MM/yyyy');

Avatar
edwardlewis

Community Member, 33 Posts

10 October 2011 at 9:36pm

Thanks for the info.. I have tried that in the past and it hasnt made any difference.

Have a look at the screenshot, I have selected 2nd October which is displayed as mm/dd yet in the _config.php i have added i18n::set_date_format('dd/MM/yyyy');

its confusing me!

Attached Files
Avatar
edwardlewis

Community Member, 33 Posts

10 October 2011 at 9:53pm

I have just managed to create something that works..

I changed a line of code in the userforms/code/editor/EditableDateField.php. I didnt really want to do that but it will be fine..

Line 51 now reads:

$('input[name^=EditableDateField]').attr('autocomplete', 'off').datepicker({dateFormat: 'dd MM yy'});

If anyone can suggest a better way of doing it then I am all ears! The form seems to work ok after a few tests..

Avatar
Willr

Forum Moderator, 5523 Posts

10 October 2011 at 10:40pm

I'd check your running the latest master version. Here's what line 51 looks like in that - https://github.com/silverstripe/silverstripe-userforms/blob/master/code/editor/EditableDateField.php#L48

Avatar
edwardlewis

Community Member, 33 Posts

13 October 2011 at 2:56am

Thanks for your help Willr.. the problem must have been down to using an older version :)