John Stamos has been in rehab for more than 2 weeks now … TMZ has learned.

Stamos checked into a residential treatment facility on June 24, according to TMZ’s sources. That was 12 days after his DUI bust in Beverly Hills.

Sources tell TMZ … Stamos’ issues are not a recent development. They’re told he’s getting treatment for a substance abuse problem that “developed over a period of time.”

You’ll recall … when Stamos was arrested, the officers felt he was in dire need of medical attention and rushed him to a hospital. He was released the next day.