increment a cell in google sheets each day

Clash Royale CLAN TAG#URR8PPPincrement a cell in google sheets each day
I have a script that needs to increment a cell every day. I have tried several methods comparing dates with the current date with the previous recorded date but that doesn't seem to work at all.
I am recording the day each time there is an entry, which I was using to increment the cell, with the following
var curDate = Utilities.formatDate(new Date(), "GMT-5", "MM/dd/yyyy")
the last thing I did to compare them was the following:
var today = parseInt(Utilities.formatDate(new Date(),"EST","D"));
var lastRecordedDay = parseInt(Utilities.formatDate(new Date(SpreadsheetApp.getActiveSpreadsheet().getSheetByName("total").getRange(challegeDay,3).getValues()),"EST","D"));
if (SpreadsheetApp.getActiveSpreadsheet().getSheetByName("total").getRange(challegeDay,3) < curDate.valueOf() ){
}
but the output told me yesterday had a bigger number than today, which should not be the case.
Date
Range#getValue()
Range#getValues()
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
Have you done any research on how to compare
Dates in Javascript? There are some great questions & answers here on Stack Overflow. Also consider the difference in the returned object betweenRange#getValue()andRange#getValues(). You will probably benefit a lot from breaking up your one-liners into manageable chunks - a common approach taken when performing basic script debugging.– tehhowch
10 mins ago