I had the same problem with my gas water heater and it turned out to be a massive accumulation of sediment in the bottom of my tank. So much that it covered the thermoport to the gas regulator and once the sediment heated up it remained hot and I just ended up with lots of luke warm water which runs out real quick. To clean it out you have to drain the tank, which may take a while because of the sediment build up, then if you have an access port on the side of the tank open it up and use a wet dri vac to suck out all the junk. If you do not have an access port you will have to unscrew the drain spigot and access the sediment layer through it. I found that in my electric water heaters a 1/2 or 3/4 piece of pvc stuffed in my vac hose works great. Then it is just lots of scraping and vacuuming to clean it out. If you are really mechanically inclined you can also remove the gas regulator and clean its thermoport out. It is probably clogged also. Good luck.