Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

DateTimePicker time picker in 24 hour but displaying in 12hr?

I'm using the bootstrap ready date time picker from http://eonasdan.github.io/bootstrap-datetimepicker/ and it's working nicely but for one issue. I have a picker setup just from time as so:

$(function () {     $('#startTime, #endTime').datetimepicker({         format: 'hh:mm',         pickDate: false,         pickSeconds: false,         pick12HourFormat: false                 }); }); 

This sets the picker to 24 hour so I can select 19:00 as a time. But when I choose this time it displays as 07:00 in the input box. Here is the setup displaying the picker:

    <div class="input-group date timePicker" id="endTime">         <input type='text' class="form-control" readonly="true"             id="endTimeContent" /> <span class="input-group-addon"><span             class="glyphicon glyphicon-time"></span> </span>     </div> 

Is there a specific data-format I can use for 24 hour in the input box?

like image 960
RegDHunter Avatar asked Feb 18 '14 07:02

RegDHunter


People also ask

How do I set TimePicker to 24 hours?

TimePicker is a view for selecting the time of day, in either 24 hour or AM/PM mode. You can use setIs24HourView(true) method with TimePicker.

How do I add time on date picker?

In the Data type box, click Date and Time (dateTime). Click Format. In the Date and Time Format dialog box, in the Display the time like this list, click the option that you want, and then click OK. In the Date Picker Properties dialog box, under Default Value, click Insert Formula .

What is the method of time and date picker?

Android Date Picker allows you to select the date consisting of day, month and year in your custom user interface. For this functionality android provides DatePicker and DatePickerDialog components. In this tutorial, we are going to demonstrate the use of Date Picker through DatePickerDialog.


1 Answers

Because the picker script is using moment.js to parse the format string, you can read the docs there for proper format strings.

But for 24Hr time, use HH instead of hh in the format.

$(function () {     $('#startTime, #endTime').datetimepicker({         format: 'HH:mm',         pickDate: false,         pickSeconds: false,         pick12HourFormat: false                 }); }); 
like image 88
Benjam Avatar answered Sep 28 '22 05:09

Benjam