JQuery Datepicker - onSelect Date Format

NimueSTEM picture NimueSTEM · Dec 16, 2013 · Viewed 7.9k times · Source

Using this:

$(function () {
    $("#datepicker").datepicker({
        onSelect: function (date) {
            var links = "http://google.co.uk/";
            window.location.href = links + date;
        }
    });
});

To populate a URL - unique for each day picked from the datepicker.

In this case - Google.co.uk used as an example with the data appended.

I would like to change the date format to be "ddmm" - so that clicking on 2nd January (and year) returns the link: http://goolge.co.uk/0201.

I can't figure out how to change the default data formatting from mm/dd/yyyy.

Example code here >>> JSFIDDLE

Answer

Spokey picture Spokey · Dec 16, 2013
$(function () {
    $("#datepicker").datepicker({
        dateFormat: 'ddmm',
        onSelect: function (date) {
            var links = "http://google.co.uk/";
            window.location.href = links + date;
        }
    });
});