This is my jQuery code. In this code #StartTime
and #EndTime
is form input tag id's.
The getting time format is 00:00 AM/PM.
The var starttimeval and endtimeval contain values of getting start and end time.
How do I compare these two times, example: if(starttimeval < endtimeval){alert(message);}
$(function() {
$('#StartTime').datetimepicker({
datepicker : false,
format : 'g:i A'
});
$('#EndTime').datetimepicker({
datepicker : false,
format : 'g:i A'
});
var starttimeval= $("#StartTime").val();
var endtimeval= $("#EndTime").val();
});
i want only time compare functionality. example getting value of starttimeval=8:00 PM and endtimeval=9:00 AM
Well, have you tried something like this :
var dateBegin = $('StartTime').datepicker('getDate').getTime():
var dateEnd = $('EndTime').datepicker('getDate').getTime();
if (dateBegin == dateEnd)
// some stuff
Seen in the doc. (I assume you are using datetimepicker from jquery ui)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With