You’re right. I only wanted to include the search term for anyone wanting to pursue this on their own. I think it is better to search the proper term and build knowledge from there than to summarize it and hope laymen understand the underlying principles.
There are ways of creating oxygen onboard submarines. The only real limits to time submerged is the amount of food the boat can carry.
Here is a video by Destin from the Smarter Every Day youtube channel explaining oxygen generation onboard submarines. https://youtu.be/g3Ud6mHdhlQ