I've inherited some code utilising the bootstrap framework.

I'm currently seeing some odd behaviour where no matter what date was last picked, the date picker always seems to open showing the month of July. Is there any particular places in the code I should be looking to see if anything funny is happening? Nothing looks out of the ordinary to me and I cannot see a method call setting it's value within the show() event.

Cheers

Mike

Nothing in the default settings? Hard to say without seeing it.

Just been digging. Traced it down to the constructor.

this.format = DPGlobal.parseFormat(options.format||this.element.data('date-format')||'mm/dd/yyyy');

and then

this.date = DPGlobal.parseDate(typeof newDate === 'string' ? newDate : (this.isInput ? this.element.prop('value') : this.element.data('date')), this.format);

where

typeof newDate === 'string' ? newDate : (this.isInput ? this.element.prop('value') : this.element.data('date'))

returns "01/01/2010" and then

this.date = DPGlobal.parseDate(typeof newDate === 'string' ? newDate : (this.isInput ? this.element.prop('value') : this.element.data('date')), this.format);

returns "Thu Jul 1 00:00:00 UTC+0100 2010".

I'm presuming something is off in the formatting?

Edit: woo 1k posts xD

Resolved.

Within the DPGlobal.parseDate method it was looking for a format of mm whereas the format was MM so was defaulting to the current month. :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.