Very simple, Date instance can be compared directly.
function compareTime(time1, time2) {
return new Date(time1) > new Date(time2); // true if time1 is later
}
When you compare two Date instance, or minus one another, the valueOf method will be called internally, which convert the instance to timestamp (millisecond accurate).