How to convert jquery UI datepicker date format for mysql-phpmyadmin datetime
type field (default) format?
please help.
Thanks.
An input element that is to be updated with the selected date from the datepicker. Use the altFormat option to change the format of the date within this field.
By default, the date format of the jQuery UI Datepicker is the US format mm/dd/yy, but we can set it to a custom display format, eg: for European dates dd-mm-yyyy and so on. The solution is to use the date picker dateFormat option.
$("#txtDate"). datepicker({ dateFormat: 'yy-mm-dd' });
From the jQuery UI site:
http://jqueryui.com/demos/datepicker/#date-formats
$(yourInput).datepicker({dateFormat: 'yy-mm-dd'})
When you are initializing the date time picker, you can pass the format.
$( ".selector" ).datepicker({ dateFormat: 'yy-mm-dd' });
jQuery UI API Documentation > Datepicker dateFormat
Or after init:
//getter
var dateFormat = $( ".selector" ).datepicker( "option", "dateFormat" );
//setter
$( ".selector" ).datepicker( "option", "dateFormat", 'yy-mm-dd' );
Also according to MySQL Reference Manual:
MySQL retrieves and displays DATE values in 'YYYY-MM-DD' format.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With