19

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/

Zanon
  • 29,231
  • 20
  • 113
  • 126
VishnuPrasad
  • 1,078
  • 5
  • 17
  • 36

4 Answers4

44

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'
});
Se0ng11
  • 2,303
  • 2
  • 26
  • 45
  • 1
    Does nothing. fiddle broken I think. – Léon Pelletier May 03 '16 at 16:33
  • What if you want format like 15-12-2017 13:17? Your format gives monday-december-2017 13:17. – FrenkyB Aug 16 '17 at 13:59
  • @FrenkyB it depend on user machine regional setting, if you want to have fixed format, try use [momentjs](https://momentjs.com/) to play around with it or create a new question for others to help you – Se0ng11 Aug 17 '17 at 03:27
  • I've found out the answer in bootstrap-datetimepicker.js - formats are listed inside. In my case it was: dd.mm.yyyy HH:ii. – FrenkyB Aug 17 '17 at 03:35
10

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/

SuperNova
  • 25,512
  • 7
  • 93
  • 64
  • 3
    Use `data-date-format="DD-MM-YYYY HH:mm:ss"` instead of `data-format="DD-MM-YYYY HH:mm:ss"`. This works – SuperNova Jun 24 '16 at 10:54
0
$('.datepicker').datetimepicker({
    format: 'dd.mm.yyyy HH:ii'
});
Mike S
  • 192
  • 3
  • 9
-1

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

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Ramzan Zafar
  • 1,562
  • 2
  • 17
  • 18