ghingaia
ghingaia

Reputation: 33

jquery.datetimepicker set time only

I used https://github.com/xdan/datetimepicker. I want to show and enter only time. My code is:

$('#dttf').datetimepicker({
    datepicker:false,
    step:15,
    format: 'H:m'});

It is showed only time from 15 minutes, starting with exact time, e.g. 9:00,9:15,9:30, etc. The problem is when I select time, 9:15 by example, it shows me 9:17, the current time. I want to show what I selected, 9:15. I tried many options, but no one seems to work.

Upvotes: 3

Views: 8284

Answers (2)

squgeim
squgeim

Reputation: 2351

You need to use H:i as the format string instead of H:m.

$("#date").datetimepicker({
  datepicker: false,
  step: 15,
  format: 'H:i'
});
@import 'https://unpkg.com/[email protected]/build/jquery.datetimepicker.min.css';
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://unpkg.com/jquery-datetimepicker"></script>


<input type="text" id="date">

Upvotes: 2

Rahul Mahadik
Rahul Mahadik

Reputation: 12271

$(function(){
   $('#example').timepicker(); 
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-timepicker/1.10.0/jquery.timepicker.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/jquery-timepicker/1.10.0/jquery.timepicker.min.css" rel="stylesheet"/>
<input type="text" id="example" />

Hope this helps you

Upvotes: 1

Related Questions