The time to prepare for the viva is after submission. There are many things you could do before submission that could help – and a lot you do while finishing your thesis will build you up for the viva – but your focus has to be on getting your thesis submitted.
The time to prepare for the viva is not a fixed period for everyone. Work and other responsibilities could mean a shorter time span for some or force activity to be spaced out over a long period than others. Preparing over the course of two to four weeks seems typical for most candidates.
The time to prepare will be better if you plan it: decide in advance how and when you will do the work. Sketch out a schedule that seems suitable and doesn’t leave you feeling stressed.
The time to prepare is getting ready for the particular challenge of the viva. It’s reading, note-making, practice and a chance to remind yourself: I can do this.