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 additional CSS style rule, so that we can see the results of selecting a date within the widget. Add the following to the <head>
of our file:
<style type="text/css"> #selecteddate...