简体   繁体   中英

JQuery Mobile DateBox calendar date July 1906

For some reason when I load the Calendar it's opening on date ... July 1906

Here is the code:

var thisTheme = o.pickPageButtonTheme;

var fd=1+self.theDate.getMonth() +'/'+ today+'/'+self.theDate.getFullYear();

if ( ( today === highlightDay || today === presetDay || dates.contains(fd) ) ) { thisTheme = o.pickPageHighButtonTheme; }




                            $('<div><a href="view-paginated.php#&ui-page=Event-Date--2011-01-31-0">' + today + '</a></div>')

                                .addClass('ui-datebox-griddate ui-corner-all ui-btn-up-'+thisTheme)
                                .attr('data-date', today)
                                .appendTo(thisRow)
                                .click(function(e) {
                                    e.preventDefault();
                                    self.theDate.setDate($(this).attr('data-date'));
                                    self.input.val(self._formatDate(self.theDate));
                                    self.close();
                                    self.input.trigger('change');
                                }).hover(
                                    function() { $(this).addClass('ui-btn-down-'+thisTheme).removeClass('ui-btn-up-'+thisTheme); },
                                    function() { $(this).addClass('ui-btn-up-'+thisTheme).removeClass('ui-btn-down-'+thisTheme); }
                                );
                            today++;
                        }
                    }

And the other part of the code is here:

 <input value="1-1-2011" name="date" type="date" data-role="datebox" id="date" data-theme="a" data-options='{"mode": "calbox", "pickPageTheme": "a", "pickPageHighButtonTheme": "e", "setDateButtonLabel": "Calendar"}'/>

It seems to be related to the FormatDate.

How can I change this please?

Thanks

Well, why it picked 1906 is beyond me - but you arbitrarily picked a date format, you'll need to let datebox know about it before it will pick it up. Give something like this a shot and see if it works:

<input value="1-1-2011" ... data-options='{"dateFormat":"mm-dd-YYYY", "mode": "calbox", "pickPageTheme": "a", "pickPageHighButtonTheme": "e", "setDateButtonLabel": "Calendar"}'/>

dateFormat takes the following:

  • YYYY : 4 Digit Year
  • MM : 2 Digit Month (zero pad)
  • mm : 1 or 2 Digit Month
  • DD : 2 Digit Day (zero pad)
  • dd : 1 or 2 Digit Day

Additionally, DateBox has had some pretty serious modifications done to how it detects dates, but please let me know if it persists, I'll try to duplicate and correct it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM