I am trying to check if a specific ISO DateTime is before 18:00
This is the simple code:
// Define the date I want to check
var targetDate = "2015-02-04T13:30:00Z";
// Parse the string into a date object
var target = new Date.parse(targetDate);
// Compare the target date againt a new date object set to 18:00:00
if(target < new Date().setHours(18 , 0, 0)){
console.log("BEFORE");
} else {
console.log("AFTER");
}
even though the time in my targetDate is set to 13:30:00 the output is always AFTER.
I have search how to compare times, and from the results I found, a simple comparison as I did should work.
I would really appreciate it if someone could point out what I am doing wrong.