Reputation: 113
I am using the Jquery datepicker from the website to allow users to select date and was wondering if it would be possible for the displayed date to be shown is the UK format of the date for example 22nd September 2012 is shown in the uk as 22/09/2012 while in American format its 09/22/2012
Upvotes: 7
Views: 14048
Reputation: 1481
As per @user2903379 question to @campervancoder answer:
$('#datepicker').datepicker({ dateFormat: 'dd-mm-yy' });
Will change the order of day/month/year
$('#datepicker').datepicker({ format: 'dd-mm-yyyy' });
Will also change the / (slash) between values to a - (hyphen) so that the date is represented in the same way that it is stored in MySQL (albeit back-to-front). Note that I also had to use the 4 letter year representation otherwise the datepicker only returned a 2 digit year.
Upvotes: 0
Reputation: 1629
As per ebram tharwat answer:
I have changed: $('#datepicker').datepicker({ dateFormat: 'dd-mm-yy' });
to $('#datepicker').datepicker({ format: 'dd-mm-yy' });
and this has worked for me
Upvotes: 0
Reputation: 1785
Use one of the following
$('#datepicker').datepicker({ dateFormat: 'dd-mm-yy' });
$('#datepicker').datepicker({ dateFormat: 'dd/mm/yy' });
$('#datepicker').datepicker({ dateFormat: 'dd-M-yy' });
$('#datepicker').datepicker({ dateFormat: 'dd-MM-yy' });
Upvotes: 3
Reputation: 8321
try this:
$('#datepicker').datepicker({ dateFormat: 'dd-mm-yy' });
$.datepicker.formatDate( format, date, settings )
Format a date into a string value with a specified format.
The format can be combinations of the following:
d - day of month (no leading zero)
dd - day of month (two digit)
o - day of the year (no leading zeros)
oo - day of the year (three digit)
D - day name short
DD - day name long
m - month of year (no leading zero)
mm - month of year (two digit)
M - month name short
MM - month name long
y - year (two digit)
yy - year (four digit)
@ - Unix timestamp (ms since 01/01/1970)
! - Windows ticks (100ns since 01/01/0001)
'...' - literal text
'' - single quote
anything else - literal text
Upvotes: 21