If you want to have a productive and effective workout, you should get at least 7-8 hours of sleep. Also, it is important that you are well hydrated and have had a good meal (not too heavy, of course, but not too light), in this case breakfast, with lots of nutritional value, especially protein. As for going to bed before midnight, I can't help you there. Just keep trying at it and eventually it will become habit. If you have had a productive day and a good workout you should be ready to hit the hay for 7-8 good hours.
you should go to bed at about 8:00pm that way your fully rested for the gym.
And if you have problems sleeping before midnight, just turn off the lights, put your and make sure its quiet. Also drink some milk, that makes everyone sleepy.