user1944305
user1944305

Reputation: 153

using jquery ui datepicker and changing date format

I can't change the date format.. about to tear my hair out. Searched the API and tried it all. Tried everything

HTML

<body>
  <p>Date:
    <input type="text" id="datepicker" />
  </p>
</body>

jQuery

$(function () {
  $(".selector").datepicker({
    dateFormat: 'dd-mm-yy'
  });
  $("#datepicker").datepicker({
    showOn: "button",
    buttonImage: "calendar_icon120121018-7997-10s714y-0_original.png",
    buttonImageOnly: true
  });
});

Upvotes: 2

Views: 1599

Answers (1)

JJJ
JJJ

Reputation: 33153

I see you have copy-pasted this line from the API:

$( ".selector" ).datepicker({ dateFormat: 'dd-mm-yy' });

.selector is a placeholder for the element you apply the datepicker to, in this case #datepicker. It's just an example, you have to modify it to fit into your own code.

Put the dateFormat option to the actual datepicker initializer, just like all the other options:

$( "#datepicker" ).datepicker({
    dateFormat: 'dd-mm-yy',
    showOn: "button",            
    buttonImage: "calendar_icon120121018-7997-10s714y-0_original.png",          
    buttonImageOnly: true    
});  

Upvotes: 2

Related Questions