0

I am using (jquery-simple-datetimepicker) for a small restaurant application. the restaurant timing is from 6 am to 12 am. My issue is the time interval starts from 00:00 to 23:30 in the dropdown but, it should show the time interval of 1 hour. for example, if the current time is 10 am the interval should start from after 6 hours that is 4:00, 5:00 till 12:00 am. and if the time is 7: pm or after then it should show time for next day that is 6:00,7:00 till 12: am. will I able to achieve in this plugin or do you prefer any other customizable plugins?

here is my code

$('#datetimepicker2').appendDtpicker({
  todayButton: true,
  step: 60,
  closeOnSelected: true,
  minuteInterval: 30,
  onSelect: function() {},

  onInit: function(handler) {
    var picker = handler.getPicker();

  }
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://www.jqueryscript.net/demo/jQuery-Date-Time-Picke-Plugin-Simple-Datetimepicker/jquery.simple-dtpicker.js"></script>
<link type="text/css" href="https://www.jqueryscript.net/demo/jQuery-Date-Time-Picke-Plugin-Simple-Datetimepicker/jquery.simple-dtpicker.css" rel="stylesheet">
<input type="text" name="date9" id="datetimepicker2">

can anyone help me out, please?

shrys
  • 5,860
  • 2
  • 21
  • 36
anusha
  • 115
  • 2
  • 14
  • Possible Duplicate: https://stackoverflow.com/questions/26971015/restricting-time-intervals-in-datetime-picker ? – Mebin Joe Jul 02 '19 at 07:15

1 Answers1

0

Try minuteInterval 60?

$('#datetimepicker2').appendDtpicker({
  todayButton: true,
  step: 60,
  closeOnSelected: true,
  minuteInterval: 60,
  minTime: "06:00",
  maxTime: "23:59",
  onSelect: function() {},

  onInit: function(handler) {
    var picker = handler.getPicker();

  }
});
Bram Verstraten
  • 1,414
  • 11
  • 24
  • minuteInterval: 60, still shows 30 minutes interval. how can I show the time interval based on the current time. for example, i want to add 6 hours to current time if the time 10 am then I want to show the interval from `4:00 5:00`, etc till `12:00`. – anusha Jul 02 '19 at 07:26
  • could you help me please? – anusha Jul 02 '19 at 07:38
  • Take a look at the [documentation](https://www.jqueryscript.net/time-clock/jQuery-Date-Time-Picke-Plugin-Simple-Datetimepicker.html). You need to set the `current` property to the new date-time. – Bram Verstraten Jul 02 '19 at 07:49
  • `current: new Date()`, I have added this, but no changes. – anusha Jul 02 '19 at 07:55
  • As you said so yourself: you need to add 6 hours to the current time. Then apply it to the date picker like you did just now. – Bram Verstraten Jul 02 '19 at 07:57
  • `var d1 = new Date (); var d2 = new Date ( d1 ); d2.setHours ( d1.getHours() + 6 ) current: d2,` – anusha Jul 02 '19 at 08:10
  • It doesn't change anything, we have to add 6 hours to minTime instead of current? – anusha Jul 02 '19 at 08:11
  • and also I want to change the time on change date event so, how can I fire event on change of date? – anusha Jul 02 '19 at 08:24