View Full Version : Compare TimeField Value with Time From Date

9 Oct 2012, 8:51 AM
Good day all!!!

I'm have a timefield "TimeField01". I'm trying to get the time from the timefield and compare it with the time from new Date().

I see in the documentation clearTime which removes the time from the date, but there is no clearDate. I would like to remove the date from the timefield and from new Date() and then compare the two times. How would I go about doing this???

9 Oct 2012, 6:18 PM
You can set the two dates to the same date, then using getTime() to convert them to miliseconds to compare.

function compareTime(time1, time2){
time1.setFullYear(1970, 0, 1);
time2.setFullYear(1970, 0, 1);
return time1.getTime() - time2.getTime();

11 Oct 2012, 8:45 AM
Thanks a lot... That worked...