Change date Format in jQuery DatePicker to English dd/mm/yy?
Question by MickySmig
I’m trying to format the date of a jQuery DatePicker to the English format ‘dd-mm-yy’, but I’m unable to get it to work. I’ve looked at all of the answers on this site and they all are using the same code as I am. Any idea why mine is not working? I have tried the two following ways:
$(function () {
$(".datefield").datepicker({dateFormat:'dd/mm/yy'});
});
$(function () {
$(".datefield").datepicker({ dateFormat: 'dd-mm-yy' });
});
Neither of these have worked. I was wondering if I had to include some other jQuery file to get the date to format to English.
Any help, as always, is greatly appreciated.
Answer by Starx
If you are trying to change it, use the setter method
$( ".datefield" ).datepicker( "option", "dateFormat", 'yy-mm-dd' );