you can apply up to three months before the date you want to leave.
The official stance is that you can have your student visa start 30 days before the course begins, but there have been anecdotal reports floating around of consulates giving start dates in July & early August for late September courses...you can ask them to post date it earlier if you wish, but of course they can always say no! Planning on arriving 30 days or less before the start of the course is probably safest, though.