user1020761
user1020761

Reputation: 41

Can't get the return value of dijit.form.DateTextBox formatted properly

I can't get my return value from a dijit.form.DateTextBox formatted properly. I create the dijit like this:

this.inputValueParam = new dijit.form.DateTextBox({constraints: { datePattern : 'yyyy-MM-dd' }}).placeAt('paramTypeSelect', 'after');

and I call the value like this:

this.inputValueParam.get('value')

I always get a date like this: wed dec 14 2011 00:00:00 gmt+0100 (cet) but I want the date in the same format as it is showed: 14-12-2011

I tried working with {constraints: { datePattern : 'dd-MM-yyyy' }} but this made no difference.

Thanks for the help!

Upvotes: 2

Views: 2917

Answers (1)

mfreitas
mfreitas

Reputation: 2405

This works for me:

dojo.date.locale.format(dateBox.value, {datePattern: "yyyy-MM-dd", selector: "date"})

It will output your date with the desired pattern

Little example here

Upvotes: 4

Related Questions