You are trying to compare a string to a Date
Object. Because the two data types do not match, javascript tries to compare them by their value and calls currentTime.valueOf()
. This evaluates to a integer like 1490781568805
. Javascript then tries to compare the string to the evaluated integer. The result is different than you might expect, because the individual char codes of the string are compared to the integer.
"2017-03-29T06:45:00.000Z" <= new Date() // string compared to the Date object
"2017-03-29T06:45:00.000Z" <= new Date().valueOf() // javascript trying get a value for the date object
"2017-03-29T06:45:00.000Z" <= 1490781568805 // evaluates to false
You can just parse your date string to a Date object using Date.parse()
Date.parse("2017-03-29T06:45:00.000Z") <= new Date() // two Date objects are compared