Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Date format in Bootstrap datetimepicker

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/

like image 639
VishnuPrasad Avatar asked Jul 24 '14 06:07

VishnuPrasad


People also ask

How do I change the date format in bootstrap?

In order to set the date format, we only need to add format of one argument and then we will add our required format, which is shown in the following example: Example 1: In this example, we are going to use dd-mm-yyyy format.

How do I change date format in 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.

Does bootstrap have a datepicker?

Bootstrap-datepicker provides a flexible datepicker widget in the Bootstrap style. Versions are incremented according to semver.


2 Answers

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'
});
like image 200
Se0ng11 Avatar answered Oct 18 '22 03:10

Se0ng11


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/

like image 33
SuperNova Avatar answered Oct 18 '22 03:10

SuperNova