Shikha thakur Shikha thakur - 1 year ago 77
TypeScript Question

compare dates which gives me wrong result

I need to compare the startDate and endDate and if

then i need to take the starting date of the month of endDate as startDate suppose my
startDate is
"startDate": "2016-05-30T00:00:00.000Z"
endDate is
"endDate": "2016-06-05T00:00:00.000Z"
then when compare need to get
but i am getting false


var c=(new Date(nestedObj.startDate)).getDate();
console.log("startdate"+" "+c);
var d=(new Date(nestedObj.endDate)).getDate();
console.log("endtdate"+" "+d);

As you can see in the below snippet

enter image description here

Any help would be appreciated.

Answer Source

try this

var c = new Date(nestedObj.startDate)
console.log("startdate"+" "+c);
var d=new Date(nestedObj.endDate);
console.log("endtdate"+" "+d);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download