views:

32

answers:

1

Hi,

I would like to retrieve the dateFormat from my datepicker default set up declaration like so:

$.datepicker.setDefaults({
    constrainInput: true,
    dateFormat: 'dd/mm/yy',
    gotoCurrent: true,
    hideIfNoPrevNext: true,
    minDate: '-1y',
    maxDate: 0,
    showOn: 'both'
});

Is there a way to retrieve this information?

I would also like to retrieve it when the above dateFormat value has been overridden when localised datepicker code is added after the above defaults.

So we have the above and then the following is added which will set dateFormat to 'yy-mm-dd':

/* Hungarian initialisation for the jQuery UI date picker plugin. */
/* Written by Istvan Karaszi ([email protected]). */
jQuery(function($){
  $.datepicker.regional['hu'] = {
    closeText: 'bezárás',
    prevText: '« vissza',
    nextText: 'elÅ‘re »',
    currentText: 'ma',
    monthNames: ['Január', 'Február', 'Március', 'Ãprilis', 'Május', 'Június',
    'Július', 'Augusztus', 'Szeptember', 'Október', 'November', 'December'],
    monthNamesShort: ['Jan', 'Feb', 'Már', 'Ãpr', 'Máj', 'Jún',
    'Júl', 'Aug', 'Szep', 'Okt', 'Nov', 'Dec'],
    dayNames: ['Vasárnap', 'Hétfö', 'Kedd', 'Szerda', 'Csütörtök', 'Péntek', 'Szombat'],
    dayNamesShort: ['Vas', 'Hét', 'Ked', 'Sze', 'Csü', 'Pén', 'Szo'],
    dayNamesMin: ['V', 'H', 'K', 'Sze', 'Cs', 'P', 'Szo'],
    weekHeader: 'Hé',
    dateFormat: 'yy-mm-dd',
    firstDay: 1,
    isRTL: false,
    showMonthAfterYear: false,
    yearSuffix: ''};
  $.datepicker.setDefaults($.datepicker.regional['hu']);
});
+2  A: 

At any point you can access the current default's from $.datepicker._defaults​, in your case:

var format = $.datepicker._defaults.dateFormat;​

You can test it here.

Nick Craver