The time limit to how long people can stay inside a submarine underwater depends on how much food supply you have in the submarine and how long that food supply lasts you.
Most submarines carry a supply of food to last the people on board the submarine for a period of 90 days or 3 months.
Most submarines don't spend longer than 3 months underwater but if need be then they could as long as they have enough food supply.