I'm facing some unusual issue.
var past = utils.stringToDate(past, 'dd-mm-yyyy', '-');
var today = new Date();
past.setHours(0, 0, 0, 0);
today.setHours(0, 0, 0, 0);
return today > past? true: false;
Above code is used to set a flag and this flag is used to decide the flow a user is. Now issue is, its working in most browsers including IE, but fails in Safari on windows (Working fine in Safari, Mac) and Opera.
past is a date that I receive from the server and the value is 27-09-2015
.
stringToDate is a function that formats date in specified format.
Test Case
past : 27-09-2015
today: 25-09-2015
Still above code returns true
in the mentioned browsers.
So the question is, is there a difference in browsers in comparing date objects in javascript and if yes, what all less known cases should I be aware of?
Also this variable is set only once in entire life cycle and is not updated anywhere else.