Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jquery ui datepicker date format

How to convert jquery UI datepicker date format for mysql-phpmyadmin datetime type field (default) format?

please help.

Thanks.

like image 830
thecodeparadox Avatar asked Jul 28 '11 11:07

thecodeparadox


People also ask

How can change date format in jQuery ui Datepicker?

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.

How do I change date format in Datepicker?

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.

How do I change the date format from YYYY MM DD in jQuery?

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


2 Answers

From the jQuery UI site:

http://jqueryui.com/demos/datepicker/#date-formats

$(yourInput).datepicker({dateFormat: 'yy-mm-dd'})

like image 22
Matt Avatar answered Oct 11 '22 15:10

Matt


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.

like image 95
Ranhiru Jude Cooray Avatar answered Oct 11 '22 16:10

Ranhiru Jude Cooray