Kin
Kin

Reputation: 4596

Is it possible to change date format in date time picker?

I found a great date time picker based on jQuery-ui http://trentrichardson.com/examples/timepicker/, but suddenly realized that i can't modify date format... Tried something like this:

jQuery('.datetimepicker').datetimepicker({
        timeFormat: 'HH:mm'
    }).formatDate('yy-mm-dd');

Can someone show an example on it?

Upvotes: 5

Views: 13515

Answers (7)

Liam Wheldon
Liam Wheldon

Reputation: 755

Just to add that none of the above worked for me, but the following did:

$(".datetimepicker").DateTimePicker({
    dateFormat: 'yyyy-mm-dd'
});

Regards

Liam

Upvotes: 0

painotpi
painotpi

Reputation: 6996

Yes it is possible, have a look at the dateFormat option in the API Documentation for the datepicker

This will work,

jQuery('.datetimepicker').datetimepicker({
        timeFormat: 'HH:mm',
        dateFormat: "yy-mm-dd"
});

Upvotes: 2

muthu
muthu

Reputation: 5461

yes it is possible to format the date. Refer the link given in this API

$.datepicker.formatTime(format, timeObj, options)

Refer the Formatting tab in this url. At the bottom of page u find the option to format a date

Upvotes: 1

saad arshad
saad arshad

Reputation: 259

POSSIBLE, heres an example link. extracting from this example souldnt be a problem i guess :)

http://jqueryui.com/resources/demos/datepicker/date-formats.html

Upvotes: 0

Aldry Wijaya
Aldry Wijaya

Reputation: 425

Try this :

jQuery('.datetimepicker').datetimepicker({ dateFormat: "D MM d, yy" });

and see this for more documentation : http://trentrichardson.com/examples/timepicker/#tp-formatting

Upvotes: 0

Tim B James
Tim B James

Reputation: 20364

You can use the code:

jQuery('.datetimepicker')
    .datetimepicker({ 
        dateFormat: 'yy-mm-dd', 
        timeFormat: 'HH:mm' 
     });

Upvotes: 6

Anton
Anton

Reputation: 32581

Try this:

This will set the date format to "yy-mm-dd"

 $.datepicker._defaults.dateFormat = "yy-mm-dd";

Upvotes: 2

Related Questions