O'Reilly logo

jQuery UI 1.10: The User Interface Library for jQuery by Dan Wellman, Alex Libby

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Changing the date format

While using the datepicker widget, you may have noticed that dates returned programmatically through the getDate method (see the Datepicking methods section) are in the default GMT date and time standard. In order to change the format of the date returned by the API, the $.datepicker.formatDate() utility method should be used. Let's take a look at how we can use this function.

In datePicker17.html, alter the date configuration object as follows:

      $("#date").datepicker({
        dateFormat: 'yy-mm-dd',
        onSelect: function(dateText, inst) {
          var d = new Date(dateText);
          var fmt2 = $.datepicker.formatDate("DD, d MM, yy", d);
          $("#selecteddate").html("Selected date: " + fmt2);
        }
      });

Save this as datePicker18.html. We need to add an ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required