The deadline to establish a new plan depends on the type of plan you want to adopt and the type of contributions you want to be available for the first plan year. If you want employees to be able to make contributions, you will generally want to allow enough time for them to do so before the plan year ends. However, if you want to adopt a safe harbor plan, your deadline to establish the plan is October 1 of the plan year assuming you establish a calendar year plan, but you will need to send a notice to participants at least 30 days before that.
To adopt a non-safe harbor 401(k) plan, the deadline is the tax filing deadline (including extensions) for your business. However, only a profit sharing contribution could be made retroactively for the first plan year if you wait until the next tax year to adopt the plan.