Is it possible to specify the display format for a dijit.form.DateTextBox?
I know that dijit.form.DateTextBox gets its date format from the user's locale by default and I know I can swtich the locale to anything I want, but I need to just specify the date format and not change anything else. Is this possible?
Thanks.
Yes, you can do something like this:
var occursOnField = new dijit.form.DateTextBox({
constraints: { datePattern : 'yyyy-MM-dd' }
, promptMessage: "yyyy-MM-dd"
, invalidMessage: "Invalid date format. Use yyyy-MM-dd"
})
Update Jan 29, 2012:
Chrome and Dojo 1.6.1 compatibility bug.
If the day of month is being padded with too many 0s, use one less d
in the date pattern to work around the bug. For example, on Google Chrome 16 and Dojo 1.6.1 : datePattern : 'yyyy-MM-dd'
will give 2010-01-001 and datePattern : 'yyyy-MM-d'
will give 2010-01-1.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With