open source guy
open source guy

Reputation: 2787

how to display only time in jquery datepicker?

I want to display only time from jquery datepicker. my current code is

$('#field-start_t_a').datetimepicker({
  showDate:false, 
   showSecond: true,

   timeFormat: 'hh:mm'
});

current output is

05/31/2013 00:12

required output is

00:12

Upvotes: 18

Views: 96305

Answers (9)

Growling Flea
Growling Flea

Reputation: 119

None of these solutions worked for me. After some playing around I saw the following worked. What I was looking for was to put a time (in hours:minutes) in a form.

<script>
    $(function() {
        $("#from").datetimepicker({
            dateFormat: '',
            datepicker:false,
            pickDate: false,
            format: "H:i",
            timeOnly:true

        });
        $("#end").datetimepicker({
            dateFormat: '',
            datepicker:false,
            pickDate: false,
            format: "H:i",
            timeOnly:true
        });

    });


</script>

When I now view my form I get the following:

enter image description here

Upvotes: 1

Teja Swaroop
Teja Swaroop

Reputation: 195

{ timeFormat: 'hh:mm tt', timeOnly: true }

Upvotes: 0

muhibun syairoji
muhibun syairoji

Reputation: 11

Try this, works like a charm !

$('.time_only').datetimepicker({
    pickDate : false ,
    format: 'hh:mm' 
});   

Upvotes: 0

mr kaveh
mr kaveh

Reputation: 1

$(function () {
   $('#datetimepicker').datetimepicker({
        format:'H:i:s',
        inline: true,
        sideBySide: true
   })
});

try this .worked for me

Upvotes: 0

adam
adam

Reputation: 191

try a code like this:

<script>
  $('#time_input').datetimepicker({
     datepicker:false,
      format:'H:i'
  }); 
</script>

Upvotes: 11

Nuno Prata
Nuno Prata

Reputation: 358

Just adding a simple solution. By adding only this , you can get a time only date picker

$('YOUR_SELECTOR').datetimepicker({
        format: "HH:mm"
});

Simple solution, hope it helps.

Upvotes: 5

prograhammer
prograhammer

Reputation: 20590

Just set dateFormat to an empty string dateFormat: ''

$('#field-start_t_a').datetimepicker({
    dateFormat: '',
    timeFormat: 'hh:mm tt'
});

(this is a little strange that you only want to set time from the datetimepicker, because you can also do $('#field-start_t_a').timepicker(); and only the time options show)

Upvotes: 21

cmd
cmd

Reputation: 101

$('.picker').datetimepicker({
    dateFormat: '',
        timeFormat: 'hh:mm tt',
        **timeOnly: true**
});

Upvotes: 8

Vineesh K S
Vineesh K S

Reputation: 1964

<script type="text/javascript">                                   

$("#time_field_id").datetimepicker({                   
dateFormat: '', 
timeFormat: 'hh:mm tt', 
timeOnly: true                                   
 }); 

</script>

Upvotes: 1

Related Questions