You didn't mention a few important things : water heater’s size (how many gallons), how many household members / how much of water are you using before it gets cold (a few showers one after another, washing machine, full tub of hot water, etc.), is it hot initially or even if you open hot side only the temperature isn’t really that high, what’s the thermostat setting, was the water heater’s behavior different a while ago while performing the same routines / using the same amount of water, warranty of your appliance, model number?.
Without all those answers I can only assume that nothing has changed in your daily habits and all of a sudden the water started getting cold much faster.
There are a few things to consider:
1. The warranty: if your water heater is still under warranty, call for service and don’t attempt to perform any repairs by yourself.
2. If the warranty period is already over, there might be a few things you can try but they vary, sometimes significantly between the models. If you have one of the expensive units, it may be worth calling a professional to have a look at it. Depending on the design it could be one of the temperature sensors, a thermostat, electronic board or its components, burner issue, hard to say…
High end water heaters have more complex designs and attempting any repairs without schematics and knowledge of this particular group of water heaters may not produce any satisfying results.