I am trying to use the =>, =<, == comparison operators on the date object to determine if a document was created in the past 3 days then display new next to the title if true.
Right now I have:
var createdDate = new Date((ctx.CurrentItem.Created));
var threeDaysAgo = new Date((new Date()).valueOf() - 1000*60*60*24*3);
if (createdDate.valueOf() >= threeDaysAgo.valueOf())
{
then display *new*
}
In this case I turned the date into milliseconds to compare, but it doesnt work. Ive tried formatting the date in multiple different ways and then comparing... still doesnt work. I've also tried using .getTime(), and it doesnt work. When I change >= to <= then it displays new for all documents, even those created 10 years ago, so atleast I know the code is correct inside the if statement.
Thanks for the help!