18
votes

I am just working on Bootstrap datetimepicker, and I am done that. A small problem is there, I tried to change the selected date format and failed. How can I fix this?

This is my code:

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

This is my jsfiddle link http://jsfiddle.net/vishnur15/8tsCt/2/

4

4 Answers

42
votes

check this jsfiddle

http://jsfiddle.net/8tsCt/4/ --not working due to reference link broken

latest version as per 2017

http://jsfiddle.net/8tsCt/166/

format must be

$('.datepicker').datetimepicker({
    format: 'DD-MM-YYYY HH:mm:ss'
});
8
votes

Please use data-date-format="DD-MM-YYYY HH:mm:ss" inside the input tag.

<input data-date-format="DD-MM-YYYY HH:mm:ss" type="text" />

See this. https://jsfiddle.net/h0jk6oq4/

0
votes
$('.datepicker').datetimepicker({
    format: 'dd.mm.yyyy HH:ii'
});
-1
votes

If you are using boot strap then there is no need to update the jQuery function just do it like

<input data-format="dd/MM/yyyy hh:mm:ss" type="text"></input>

Hope this will help