最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to add time in daterangepicker - Stack Overflow

programmeradmin1浏览0评论

I need to add time in a daterangepicker using jQuery and JavaScript. I am explaining my code below.

<input class="form-control" name="startgroupdate" id="stdate" type="text" placeholder=""  onfocus="removeBorder('stdate')">
$('input[name="startgroupdate"]').daterangepicker({
    singleDatePicker: true,
    showDropdowns: true,
    drops: "up",
    minDate: '01/01/2012',
    maxDate: '12/31/2017'
});

Here only the date is ing from the calendar, but I need to add also the time, so the result should be like "03/04/2017 12 10 PM".

I need to add time in a daterangepicker using jQuery and JavaScript. I am explaining my code below.

<input class="form-control" name="startgroupdate" id="stdate" type="text" placeholder=""  onfocus="removeBorder('stdate')">
$('input[name="startgroupdate"]').daterangepicker({
    singleDatePicker: true,
    showDropdowns: true,
    drops: "up",
    minDate: '01/01/2012',
    maxDate: '12/31/2017'
});

Here only the date is ing from the calendar, but I need to add also the time, so the result should be like "03/04/2017 12 10 PM".

Share Improve this question edited Apr 5, 2017 at 12:57 Paul Roub 36.4k27 gold badges86 silver badges95 bronze badges asked Apr 5, 2017 at 11:50 user5443928user5443928 0
Add a ment  | 

3 Answers 3

Reset to default 7

Check this out..You need to add time property and daterangepicker js

<!DOCTYPE html>
<html>

<head>
  <script data-require="jquery@*" data-semver="3.1.1" src="https://ajax.googleapis./ajax/libs/jquery/3.1.1/jquery.min.js"></script>
  <link data-require="bootstrap@*" data-semver="4.0.5" rel="stylesheet" href="https://maxcdn.bootstrapcdn./bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" />
  <script type="text/javascript" src="https://netdna.bootstrapcdn./bootstrap/3.3.2/js/bootstrap.min.js"></script>

  <link rel="stylesheet" href="style.css" />
  <link href="daterangepicker-bs3.css" rel="stylesheet" type="text/css" />
  <script src="moment.js"></script>
  <script src="https://cdnjs.cloudflare./ajax/libs/bootstrap-daterangepicker/2.1.25/daterangepicker.js"></script>
  <script src="script.js"></script>

</head>

<body>
  <h1>Hello Plunker!</h1>
  <input class="form-control" name="startgroupdate" id="stdate" type="text" placeholder="">
  <script>
    $(function() {
      $('input[name="startgroupdate"]').daterangepicker({
        timePicker: true,
        locale: {
          format: 'MM/DD/YYYY h:mm A'
        },
        singleDatePicker: true,
        showDropdowns: true,
        drops: "down",
        minDate: '01/01/2012',
        maxDate: '12/31/2017'
      });
    });
  </script>
</body>

</html>

Yo have to add property

 timePicker: true

may this links helps https://www.daterangepicker./#example2

You need to add the timepicker flag to daterangepicker.

$('input[name="startgroupdate"]').daterangepicker({
    timePicker: true,
    timePickerIncrement: 30,
    singleDatePicker: true,
    showDropdowns: true  
    drops: "up",
    minDate: '01/01/2012',
    maxDate: '12/31/2017'
});
发布评论

评论列表(0)

  1. 暂无评论