I would like to make sure that I am comparing the "date" element of each format and excluding any time element. Then, when both dates are converted to milliseconds, just compare the values. You could do something like this. If the dates are equal, they return 0 if the first date is less than the second and then returns -1, otherwise returns 1.
Javascript
function compareDates(milliSeconds, dateString) { var year, month, day, tempDate1, tempDate2, parts; tempDate1 = new Date(milliSeconds); year = tempDate1.getFullYear(); month = tempDate1.getDate(); day = tempDate1.getDay(); tempDate1 = new Date(year, month, day).getTime(); parts = dateString.split("/"); tempDate2 = new Date(parts[0], parts[1] - 1, parts[2]).getTime(); if (tempDate1 === tempDate2) { return 0; } if (tempDate1 < tempDate2) { return -1; } return 1; } var format1 = 1381308375118, format2 = "2013/08/26"; console.log(compareDates(format1, format2));
Jsfiddle on
source share