Water runs cold after about 10 minutes of showering! Also there was black stuff coming out of bath pipe before. Just got a new water heater and it didn't fix the hot water problem :(. What could it be?
The black stuff should've been from the new Water Heater installation & should've cleared right up. The Plumber likely had to shut-off the building's water & the valve had some deposits scraped off from operation of the valve.
But, the hot water running out so quickly is pointing to a hot water line leak. Since it wasn't noticed by anyone you could have pipes under the concrete slab of the ground floor or basement.
3-ways to discover & confirm a leak.
1 - Listen for hissing or slight high pitched rattling sounds or any unknown sound actually in the shower before turning anything on in the shower.
2 - Walk around in bare feet on the concrete slab to find a warm or hot spot.
3 - Turn off the Hot Water Valve at the Water Heater until your next shower & then turn the hot water back on just before your shower. Just turn it on a little & not wide open just 1/4 of the way.
If 1 & 2 don't find anything initially, but 3 does improve the showering then you do have a leak & go turn off the Hot Water after you're done using it again & until your next need.
Turning off the Hot Water Valve stops the hot water from leaving the tank & you get a full tank heating. Turning it back on just a little usually doesn't effect showering but limits how much hot water is lost through the leak. You can use the Water Heater this way indefinitely until the leak is found & repaired.
Perhaps you are simply using all the hot water in the tank. After all, 3 gallons per minute is a fairly low flow, but will empty a 30 gallon tank in 10 minutes.
To test this, measure how much water comes out of your shower. A bucket and a stopwatch should suffice. Put 1 gallon of water in the bucket (4 quarts or two 2-liter soda bottles worth) and mark the water level in the bucket. Then set the shower the normal way you use it (temp and flow) and time how long it takes to fill the bucket to that level from the showerhead. You can also switch the diverter so it goes down to the tub spigot if that's easier, but the flow may be higher this way, so it may be a false reading. You can also try turning off the "cold" and measuring only the "hot", but this may make the bucket adventuresome to hold. Now that you have a seconds-per-gallon number, go down and look at the water heater capacity (on its nameplate or EPA tag) and you can figure how many seconds of hot shower you get.
Why did you replace the hot water heater? Did it reduce in capacity? By chance, did this coincide with turning the temperature down (for safety)? Doing that means using a lot more hot water to get the same comfort temperature, so you will empty the tank much faster. I once had to choose between scalding temps or short showers.
With a tanked heater, when the tank is empty, you're done. It is impossible for a tanked heater to heat water continuously; if it could, it would be an on-demand heater and it wouldn't need a tank! If you are a long-shower junkie like me, you want an on-demand heater. You can shower all day, but the gas ones are pricey, and the electric ones are reasonably priced but require very impressive electrical service.
I have seen similar behaviour in a system that had a "short circuit" in the plumbing where cold water was allowed to enter the hot water pipes. In my case it was an old two knob faucet used to control a shower where a shutoff valve had been installed after the hot & cold mix point (the shutoff was right at the shower head). The shower head shutoff was closed and both hot and cold faucet valves were left open. Drawing hot water at some other location in the house would cause cold water to be sucked across the open valves and into the hot water pipes. The result was tepid water in the hot pipe. The time I saw this happen, it took about 10 minutes for the effect to be noticeable.