Detox usually runs five to ten days. Residential stays are most often 30, 60 or 90 days. Day treatment and intensive outpatient run six to twelve weeks each. Outpatient counseling can continue for months. Medication for opioid use is often ongoing. These are typical ranges from program descriptions, not a rule; the program and your insurance plan decide the length together, usually in reviews every week or two.
Ask every program what happens when the planned length ends and who arranges the next step. A program that cannot answer that is a program to be careful with.