The ideal time to apply for an ESTA is several weeks before your planned departure date for the United States. This will allow you to be prepared for any eventuality, even though the usual processing time for the ESTA by the US authorities is 72 hours maximum. You may have to reapply if your application is rejected or you may have to go through a standard visa procedure.