jQuery Quick Tip #2 – Changing Date Format

Posted on by Matt

Time for jQuery Quick tip number 2!  This time, it concerns the datepicker that is built into jQuery UI.

So you’ve implemented the jQuery UI datepicker using the code below:

$(function() {

However this returns by default the date back in US format i.e. The 22nd July would be 07/22/09 . Thats ok if your US based but what if your UK based for example, how do i return the date in UK format i.e. 22/07/09 ?

Well, it’s fairly simple actually! All you need to do is insert the date format within the last set of parentheses eg.

$(function() {
$("#datepicker").datepicker({dateFormat: 'dd/mm/yy'});

This now returns UK format date, you can also put other date format in here, see this link for more details on how to write the date format!

18 Responses to jQuery Quick Tip #2 – Changing Date Format

Leave a Reply