views:

93

answers:

3

I am using jquery datetime picker. it is showing date in "yy/MMM/dd hh:mm:ss" format on selecting the date and time. i am not able to change its format. How can i change it to my custom format "dd/MM/yyyy hh:mm"

+1  A: 

After initializing the datepicker

$('#selector').datepicker();

you could do

$('#selector').datepicker('option', 'dateFormat', 'dd-mm-y');

See THIS for possible formats

Pedro Gil
+3  A: 

You can set it at initialization like this:

$([selector]).datepicker({
    dateFormat: "dd/MM/yyy hh:mm"
});

Or you can set the date format after initialization using the following code:

$( ".selector" ).datepicker( "option", "dateFormat", 'yy-mm-dd' );

Emil Badh
i m using datetime picker as shown in this example not the datepicker as shown here http://rohitaggarwal.wordpress.com/2009/05/22/jquery-calendar-date-time-picker/
Tassadaque
In that case there's both bad and good news. The bad is that that particular date picker does not have support for setting the date format. The good news is that at http://blog.w3visions.com/2009/04/date-time-picker-with-jquery-ui-datepicker/#comment-61 someone has written how to implement support for setting the date time format.
Emil Badh
A: 

$(function(){

var pickerOpts = {

    dateFormat:"d MM yy"

};  

$("#date").datepicker(pickerOpts);

});

Zinab Taher
I am using Datetime picker not datepicker.
Tassadaque