Another one of those questions that I am often asked but has more than one answer!
In short it really depends on a number of factors:
Your current level of fitness.
If you are starting out there is no problem at all with 5-10 mins – Seriously something is better than nothing! The key thing is not to over do it – starting slowly and gently and gradually building up is much better than coming at it full on, feeling like you have been hit by a bus the next day and never wanting to come back! That said, even for the fittest it is seldom necessary to go beyond 60 mins.
What you are aiming to achieve
This of course has a significant bearing on how long you are gym side! (as well as what you do when you are in there) It also goes a long way toward explaining the general guidelines of 30mins a day 5x week. For those people that are de-conditioned and approaching regular activity/exercise for the first time this is a great goal to work towards. If you are chasing a beach body or want to run a marathon it might not cut it!
The type of workout that you are doing:
Whether its weight training, functional workouts, cardio or classes the relative intensity will often dictate the amount of time you should spend in the gym, not to mention the amount of days you may need to spend recovering from your workout.