TimePicker 24小时格式

时间:2018-01-25 07:23:57

标签: jquery timepicker

我在我的项目中使用timepicker但是我需要这个时间在24小时没有上午,下午 这是我的代码



<div class="bootstrap-timepicker" >
<label for="email" class="col-sm-2 control-label">From Time</label>
<input type="text" id="from_time" class="form-control timepicker" style="width: 30%;" >
<label for="email" class="col-sm-2 control-label">To Time</label>
<input type="text" id="to_time" class="form-control timepicker" style="width: 30%;" >
<!-- /.input group -->
</div>
&#13;
&#13;
&#13;

但是这段代码给了我这样的12小时格式

04:00 PM  

但我想要的是什么

16:00

9 个答案:

答案 0 :(得分:1)

如果您使用的是bootstrap

$('.time-picker').timepicker({
        showMeridian: false     
    });

或者您可以尝试这个,而不是测试:

  $('input.timepicker').timepicker({ timeFormat: 'HH:mm:ss p' });

希望这会对你有所帮助。 享受

答案 1 :(得分:1)

如果您使用的是jquery timepicker

$('input.timepicker').timepicker({ timeFormat: 'HH:mm:ss', });

如果您使用的是bootstrap timepicker

$(function () {
    $('#datetimepicker4').datetimepicker({
        pickDate: false,
        minuteStepping:30,
        format: 'hh:mm',
        pickTime: true,
        defaultDate: new Date(1979, 0, 1, 8, 0, 0, 0),
        language:'en',
        use24hours: true
    });
});

答案 2 :(得分:1)

这对我有用。

Private Sub Charts_Load(sender As Object, e As EventArgs) Handles MyBase.Load Access.ExecQuery("SELECT CompetitionDate.FirstName, CompetitionDate.LastName, CompetitionDate.Wins FROM CompetitionDate ORDER BY Wins") Dim ChartArea2 As ChartArea = New ChartArea() Dim Legend2 As Legend = New Legend() Dim Wins2 As Series = New Series() Dim Chart2 = New Chart() Me.Controls.Add(Chart2) ChartArea2.Name = "ChartArea2" Chart1.ChartAreas.Add(ChartArea2) Legend2.Name = "Legend2" Chart2.Legends.Add(Legend2) Chart2.Location = New System.Drawing.Point(13, 13) Chart2.Name = "Chart2" Wins2.ChartArea = "ChartArea2" Wins2.Legend = "Legend2" Wins2.Name = "Wins" Chart2.Series.Add(Wins2) Chart2.Size = New System.Drawing.Size(800, 400) Chart2.TabIndex = 0 Chart2.Text = "Total Wins" Chart2.Series("Wins").XValueMember = "FirstName" Chart2.Series("Wins").YValueMembers = "Wins" Chart2.DataSource = Access.DBDT.TableName("CompetitionDate") End Sub

答案 3 :(得分:0)

您可以使用type:"time"

<div class="bootstrap-timepicker" >
  <label for="email" class="col-sm-2 control-label">From Time</label>
  <input type="time" id="from_time" class="form-control timepicker" style="width: 30%;" >
  <label for="email" class="col-sm-2 control-label">To Time</label>
  <input type="time" id="to_time" class="form-control timepicker" style="width: 30%;" >
  <!-- /.input group -->
</div>

请注意,这在FireFox中不起作用。

  

Firefox的时间控制与Chrome非常相似,只是它没有向上和向下箭头,它是一个12小时的时钟(有一个额外的插槽来指定AM或PM)。

答案 4 :(得分:0)

尝试以下代码

<html>
<head> ... </head>
<body>
...
<form ... >
...
<input type="text" class="timepicker" name="timepicker" />
...
</form>
...
</body>

<script src="//code.jquery.com/ui/1.10.2/jquery-ui.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/timepicker/1.3.5/jquery.timepicker.min.js"></script>

<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/timepicker/1.3.5/jquery.timepicker.min.css">

<script type="text/javascript">
       $(document).ready(function() {
         $('.timepicker').timepicker({
                timeFormat: 'HH:mm',
                interval: 60,
                defaultTime: '10',
              });
       });
     </script>
</html>

答案 5 :(得分:0)

对于jQuery timepicker,您需要将'timeFormat'选项与PHP的date()格式语法一起使用:

$('.time').timepicker({
  'timeFormat': 'H:i'
});

文档:https://github.com/jonthornton/jquery-timepicker#timepicker-plugin-for-jquery

答案 6 :(得分:0)

您可以使用此格式获取24小时格式:

$('input.timepicker').timepicker({
timeFormat: 'h:i',});

答案 7 :(得分:0)

您可以使用此

$('.timepicker').timepicker({
    disableMousewheel: true,
    icons: {
        up: 'la la-angle-up',
        down: 'la la-angle-down'
    },
    showSeconds: true,
    showMeridian: false,
    defaultTime: new Date()
}).on('changeTime.timepicker', function (e) {

    var hours = ('0' + e.time.hours).slice(-2);
    var minutes = ('0' + e.time.minutes).slice(-2);
    var seconds = ('0' + e.time.seconds).slice(-2);

    $(this).val(hours + ':' + minutes + ':' + seconds);
});

答案 8 :(得分:0)

尝试一下:

这就是我添加时间字段的方式。

<input id="timepicker3" type="text" class="form-control event-time-from" name="event-time-from" value="10:30 AM" data-provide="timepicker" placeholder="HH:MM" required>

这就是它接受24小时格式的时间的原因。

$(".event-time-from").timepicker({ showMeridian: !1});