How to compare two timestamps in this format in javascript?

comparison, date, javascript

Solution

You may need to do something like this,

d1 = new Date("2014-01-15 00:00:00.0");
d2 = new Date("2014-01-16 00:00:00.0");

if ((d1 - d2) == 0) {
    alert("equal");
} else if (d1 > d2) {
    alert("d1 > d2");
} else {
    alert("d1 < d2");
}

Working fiddle

Problem

I have two timestamps formats say, ``` a='2014-01-15 00:00:00.0' b='2014-01-16 00:00:00.0' ``` How to compare and find if b is after a or not?

Original source