2
I want to create a function group that compares dates in Typescript. So far I have the following:
function amanhaOuDepois(date: Date): boolean{
if(date > (new Date()))
return true;
return false;
}
function ontemOuAntes(date: Date): boolean{
if(date < (new Date()))
return true;
return false;
}
function hoje(date: Date): boolean{
if(date == (new Date()))
return true;
return false;
}
All functions are working as expected, minus the function amanhaOuDepois
, who always returns false
. How can I compare only the date of a type object Date
, ignoring the hour, minutes and seconds?
only one addendum:
(date < (new Date()))
this already returnstrue
orfalse
... then just give onereturn date < new Date();
– novic
It was to make the code a little more readable hehehe, but yes, you’re right
– Arthur Siqueira
Has two functions with the same name:
amanhaOuDepois
... note this ... I think typo.– novic
@Virgilionovic corrected, thank you
– Arthur Siqueira