During my PPL. , my instructor certainly mentioned 30 and 45 minutes in the context of VFR and IFR flights, but I don't remember these being presented as legal limits, they were recommendations. And I seem to recall that he said he'd like an hour when IFR, as a personal opinon.
Perhaps the 30 and 45 were recommendations in the FI syllabus? NO doubt an FI will comment in due course.
Personally, I would always be happy to carry the max amount of fuel the aircraft would take without going overweight, not so much going over the top as utlising the capability of the aircraft and bearing in mind that fuel in the bowser is of little use when airborne, i.e. fuel offers options for changes of plan.