Just ignore any rule of thumb you hear.
My advice would be to start your homework as soon as possible (well OK, I've never been able to follow that part

), and just go to the library or somewhere where you can truly concentrate. If you have time pressure you are just going to look for the answers or relevant equations without really understanding what you are doing. Instead, just go and expect to be there the entire day and don't set any specific goals about finishing the assignment. Find the relevant parts of the course for a given problem, but don't even try to solve the problem, just try to understand everything that is confusing about those sections of the course. Even if you think you have the general concepts, make sure you know exactly where every equation came from, etc. After a while you will look at the question and you will KNOW you are ready to solve it.
For some classes, this entire process may take 2 hours. For others you may be there the whole entire night and you still haven't solved a single question. That will probably feel discouraging but it may also be the time when you learn the most.
When you give yourself a lot of time like that, that's when you can actually enjoy what you are learning. When you are just trying to finish the assignment, not only will you understand it less, but you also won't enjoy it because you'll be worrying about getting points and grades too much.
Also, if you approach every single homework this way, you shouldn't have to study much at all when it comes to time to take exams. You'll just need to brush up on everything.