Luke’s Jedi training was an important part of his hero’s journey in the original Star Wars trilogy, but the story never revealed how long he was on Dagobah for before leaving for Cloud City.
In the days of the Republic, Padawans would train for years until they were initiated into the order as a Jedi Knight. And even then, they wouldn’t survive long in the field. Luke Skywalker, meanwhile, didn’t have the luxury of time. In fact, his training with Yoda was cut short when he sensed through the Force that his friends were in danger. The two Jedi Masters tried to dissuade him, of course, but Luke took the bait and faced his father regardless, who resoundingly defeated him in the ensuing lightsaber duel.
The way all of these events are portrayed, though, makes it seem like he was only on Dagobah for a few days, at most. But despite the movie showing his journey concurrently with Han and Leia on the Millennium Falcon, it seems that the young Skywalker was with Yoda way longer than we originally thought.
This information is courtesy of the new book From a Certain Point of View: The Empire Strikes Back, which retells the story from the perspective of other characters. One of these chapters, from Kenobi’s POV, shows the Jedi Master scoffing at Luke for thinking that he’s ready, and here’s how it reads:
“‘But I’ve learned so much since then!’ Luke protests, and I resist the urge to snort. As though carrying Yoda on your shoulders and eating his terrible cooking for a few weeks makes you a Jedi.”
The recently published Star Wars title pretty much confirms that Yoda trained Luke more extensively than the movie’s runtime could grant and as ScreeRant notes, he was there for roughly a month. Obi-Wan even remarks to himself that he has had to “facilitate a group therapy session” between the two of them on several occasions, meaning that he certainly spent considerable time on Dagobah.