Copy Date to Next Cell Automatically

To copy the date from one cell to the next cell over. Featured in this youtube video: https://youtu.be/_FEnrYyVE7k

Code.gs






function dailyVisit() {

  var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Visits")
  var data = sheet.getRange("E3:E").getValues()
  var today = new Date().setHours(0,0,0,0)

  data.forEach((row,index) => {
    const cellDate = row[0]

    if (cellDate.setHours(0,0,0,0) === today ){
      const rowNum = index + 3
      sheet.getRange(rowNum,4).setValue(cellDate)
      sheet.getRange(rowNum,5).clearContent()
    }
  })
  
}