It's not just the gym you need to think about, it's your diet as well. You could do, say, an hour in the gym and then completely counter the effect by eating one chocolate bar, for example. It will only work if you take the time to work out how much you're eating as well as how much exercise you're doing. If you eat more than you burn you will still fail to lose weight, no matter how much exercise you're actually completing.
It can be ridiculously easy to get back from the gym and think "oh I'll have a piece of bread now, I've earned it" (extra 100 cals plus any spread), or "I'll have a bar of chocolate" (at least 250 cals depending on which one you choose) and that's not even to mention the fact that you may be eating portion sizes that are too large in the first place.