Dojo Date Picker – setting the date format

We’ve just implemented a Dojo Date picker to replace an old calendar tool we were using.

In testing, the date picker correctly defaulted to the European date format of dd/mm/yyyy. However, all this testing was on PCs. Testing the same code on my Mac in Safari, the date format has switched to US format. My Mac is setup as a UK machine with UK date format, but it’s still defaulted to incorrect date format.

As we’re a University with many international staff and students, assuming that their computers will be set to European format would not be sensible and as the date is being stored in Domino and Oracle we need control over the date formats to ensure the correct date objects are created.

Luckily there’s a very simple solution. If you’re using html markup and the dojo parser to generate the date picker, you simply have to add:

constraints={datePattern:’dd/MM/yy’}

to your input box’s html and it will default to the European format.

Leave a Reply