2

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
  });
});
3
  • code shows dateformat so you haven't explained what the issue is. Please be more specific and if problem relates to external data provide sample Commented Jan 20, 2013 at 16:23
  • Define dateFormat in #datepicker Commented Jan 20, 2013 at 16:24
  • i want the date to be = day month year, instead of the default = month, day, year Commented Jan 20, 2013 at 16:25

1 Answer 1

2

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    
});  
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.