Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to display only time in jquery datepicker?

Tags:

jquery

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
like image 898
open source guy Avatar asked May 31 '13 17:05

open source guy


People also ask

How to show time in datepicker jQuery?

DateTimePicker allows you to define the text representation of a date and time value to be displayed in the DateTimePicker control. The format specified is achieved by the dateTimeFormat property. Default value of this property is M/d/yyyy h: mm tt.

How to use datepicker using jQuery?

The datepicker is tied to a standard form input field. Focus on the input (click, or use the tab key) to open an interactive calendar in a small overlay. Choose a date, click elsewhere on the page (blur the input), or hit the Esc key to close. If a date is chosen, feedback is shown as the input's value.

How to create datepicker in jQuery?

JavaScript Code: $( function() { var from = $( "#fromDate" ) . datepicker({ dateFormat: "yy-mm-dd", changeMonth: true }) . on( "change", function() { to. datepicker( "option", "minDate", getDate( this ) ); }), to = $( "#toDate" ).


2 Answers

try a code like this:

<script>
  $('#time_input').datetimepicker({
     datepicker:false,
      format:'H:i'
  }); 
</script>
like image 21
adam Avatar answered Sep 17 '22 15:09

adam


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)

like image 128
prograhammer Avatar answered Sep 17 '22 15:09

prograhammer