Click here to Skip to main content
15,914,444 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How chould i check if timepicker1s Value is greather than or equals to timepicker2?,
JavaScript
$("#timepickerTo").timepicker({
      timeFormat: 'HH:mm',
      minTime: '08:00',
      maxTime: '17:00',
      step: "30"

  });
  $("#timepicker").timepicker({
      timeFormat: 'HH:mm',
      minTime: '08:00',
      maxTime: '17:00',
      step: "30"});
  var getValueTime=($("#timepicker").val());
  var getValueTimeTo=($("#timepickerTo").val());
  if(getValueTime>= getValueTimeTo)


  });



UPDATE
======================
JavaScript
$("#timepickerTo").timepicker({
            timeFormat: 'HH:mm',
            minTime: '08:00',
            maxTime: '17:00',
            step: "30"
   
        });
        $("#timepicker").timepicker({
            change: function () {
                var start = new Date("2014-12-12+T" + $("#timepicker").val()+":00"+"Z");
                start = start.getTime();
                var end = new Date("2014-12-13+T" + $("#timepickerTo").val() + ":00" + "Z");
                end = end.getTime();
                if (end >= start) {
                    alert("OK");
                }
            }
            });


Nothing happens?
Posted
Updated 15-Dec-14 2:43am
v3

1 solution

you can create new Date from your time strings and compare
JavaScript
var start = new Date("November 1, 2014 " + $("#timepicker").val());
start = start.getTime();
var end = new Date("November 1, 2014 " + $("#timepickerTo").val());
end = end.getTime();
if(end >= start)
{
     alert("OK");
}


DEMO[^]
 
Share this answer
 
v2
Comments
Kurac1 15-Dec-14 8:41am    
I will update my question in the top nothing happend
Kurac1 15-Dec-14 8:53am    
Start gets NaN
And end gets Sun Nov 2 00:00:00 UTC+1 0100 2014
DamithSL 15-Dec-14 9:43am    
I have added jsfiddle sample, please check

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