Make compare between today and another date

private eventDate: Date = new Date('July 16, 2019 12:24:00');//this is another date

private today : Date=new Date();



its not working as this like but when ı make below hello is displayed



ı mean private today : Date=new Date(); that is not getting today date please help me how can ı get current date

Hi Tubiss,

You shouldn’t compare two objects with “==” / “!=” operator.

If you want to check if this two dates are the same you can use

if ( === this.eventDate.getTime()) {}

You can also check if its the same day etc.

See more here

I use and recommend date-fns for all tasks like this.

var day = new Date();
Tue Jul 16 2019 15:11:12 GMT-0400
if you only want to compare date
you can use day.substr() to get what you want from this string