Click here to Skip to main content
15,900,725 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have one timepicker and one input box when selecting value from timepicker i want to add that value to the input box, and add 30 minutes also?

JavaScript
$("#timepicker").timepicker({
                change:function() {
                    
                    var getValue = $("#timepicker").val();
                    var start = new Date(getValue);
                 
                    var newDate = start.setTime(start.getTime() + 30 * 60 * 1000);
                    start = new Date(newDate);
                  {
                      $('#timepickerTo').timepicker(start.getTime());
                    }
                },
               timeFormat: 'HH:mm',
               minTime: '08:00',
               maxTime: '17:00',
               step: "30"
              
           
           }



UPDATE====

C#
$("#timepicker").timepicker({
                change:function() {
                    var getValue = $("#timepicker").val();

                    var get = new Date();
                    get.setTime(getValue);

                    var dt = new Date(get);

                    var newDate = dt.setMinutes(dt.getMinutes() + 30 * 60 * 1000);
                    getValue = new Date(newDate);

                    $('#timepickerTo').val(getValue);


                },



var get= new Date() gets invalid date, my time is 08:00
Posted
Updated 8-Dec-14 1:57am
v2

1 solution

After reading all you post in the subject of timepicker I can see that you need no two timepickers...
After you select time in the first timepicker you allow select only a value 30 away from the second. It means if you select 8:00 int the second you must select 8:30, if you select 10:00 you must pick the 10:30 value from the second.
So why use two timepicker. Use one and compute the end value from the one selected in the first...
 
Share this answer
 
Comments
Kurac1 8-Dec-14 7:20am    
I dont use 2 datepickers i only have 1, the name of if it is just timepicker
Kornfeld Eliyahu Peter 8-Dec-14 7:22am    
So who is timepickerTo?
Kurac1 8-Dec-14 7:24am    
<input type="text" readonly="readonly" size="8" id="timepickerTo" /> this is were i want to display the selected value from timepicker +30 minutes? so from selectedtime from timepicker plus 30 minutes add in timepickerTo Input
Kornfeld Eliyahu Peter 8-Dec-14 7:26am    
That's not what you asked and that's not what you are do!
This line, $('#timepickerTo').timepicker(start.getTime());, turns timepickerTo to a timepicker control!!!
Do $('#timepickerTo').val(start); to see computed value...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900