Four years ago, Justice Antonin Scalia passed away in Feb. 2016
This vacancy arose during Obama's final year as president, and shortly after Scalia's death was announced, Republican Senate leaders declared that because Scalia's seat had become vacant during an election year, the Senate would not even consider a nomination from the president. Senate Democrats criticized the move as being unprecedented and responded saying that there was sufficient time to vote on a nominee before the election
Link
Thus to be consistent - Trump should wait until after the election to nominate - assuming he wins re-election
Both sides agree, that if there is not an opposition president, they can confirm at any time, and both sides would. Do you really believe a democrat senate would not have confirmed Garland? In a heartbeat.
The basic rule is, the Senate has the choice to defer during an election year. That's it.
If dems ran the senate today, they would defer. If they ran the Senate during Obama's last term, they would have confirmed.
Trump knows this, and will do it if logistically possible.
TRUMP TO GOP: FILLING SUPREME COURT VACANCY AN OBLIGATION TO VOTERS