The date was Nov. 12. The place was deep in the bowels of Raymond James Stadium in Tampa Bay. It was after midnight — both on the clock that night and seemingly on a team’s season — which appeared on the brink of disaster.

The Dolphins were fin deep in the bullying scandal involving offensive lineman Richie Incognito and Jonathan Martin. Outraged national media were swarming their players and head coach, Joe Philbin. Then — exacerbating the already untenable situation — this happened: The Dolphins lost to the 0-8 Buccaneers in front of a national television audience.

Before the game, Dolphins owner Stephen Ross, who rarely surfaces to speak to the media, conducted an emergency damage-control press conference in an effort to calm the storm and restore order.

After the game, in a hastily set up interview area outside the visitor’s locker room, reporters were 20 deep around Philbin, peppering him with questions about the scandal and its effect on his team. Inside the cramped locker room, reporters and players tripped over each other trying to maneuver.

It was an absolute mess, one no one could foresee the Dolphins escaping, not with the current regime still in place. So calls came from everywhere to fire Philbin and general manager Jeff Ireland, to “blow the place up” and start over.

Mistakes had been made by all parties — beginning with Ireland, for some alleged comments he made to Martin’s agent and for allowing this thing to fester under his watch. Philbin, who clearly had zero pulse on his own locker room, was culpable. So, too, were Ingocnito for his Neanderthal, boorish behavior and Martin for quitting on his teammates.

So when Philbin stood before dozens of reporters outside the visitor’s locker room that November night in Tampa and deflected questions while his players inside the locker room implored reporters to leave them alone and allow them to focus on football, there appeared to be no way out of this for the Dolphins.

Miami Dolphins guard Richie Incognito, center left, and tackle Jonathan Martin, center right, sit on the bench in the second half of an NFL football game in September.Photo: AP Photo/Bill Feig

But since that harried night, where the Dolphins appeared to be drowning in their own ignorance and foolishness, they are 3-1 and front runners in the race for the last AFC wild-card playoff berth entering Sunday’s critical game against the Patriots at Sun Life Stadium.

“It is a good story, no question about it,” former NFL quarterback Dan Fouts, the NFL analyst who has called three of the Dolphins games for CBS this season, including Sunday’s upset win over the Steelers in the snow at Pittsburgh. “Philbin has done a good job the way he’s handled things. One of players talked to me about how Philbin didn’t put a lockdown in the locker room as far as players speaking to media. He said to them, ‘Speak your heart.’

“You’ve seen the quotes. You know what the players have said. That was a unifying thing for Philbin to do for his team, and we’re now seeing the results of that.”

The 7-6 Dolphins have not won a playoff game since 2000, the year after Dan Marino retired. So you get the picture: This has not exactly been a wildly successful franchise for the last two decades.

But the Dolphins, who have missed the playoffs the past four seasons, are in their best position to get to the postseason since their last visit there, in 2008.

Not only are they one of the hottest teams in the AFC, having won four of their past six games, the 7-6 Ravens, who are their closest competitors for the last playoff berth, face a daunting three-game schedule to close out the season (at 7-6 Detroit, vs. 10-3 New England and at 9-4 Cincinnati). The Dolphins, after the Patriots, face the 4-9 Bills in Buffalo and host the 6-7 Jets.

Can they do this? Can the beat the Patriots, whom they have not defeated since 2009, and carry this thing into the playoffs?

“Yeah, why not?” Dolphins receiver Mike Wallace said this week. “We feel we’re just as good as anybody.”

“Just as good” is a stretch. But based on what they have overcome, the Dolphins certainly are at least as mentally tough as any team in the league.

“I have to give Joe Philbin tremendous credit for the focus that he demanded from all of us to stay on task,” former Packers head coach and current Dolphins offensive coordinator Mike Sherman said this week. “You talk about going through some very difficult times. As a head coach, I never had to endure what he’s had to endure this past season with the distractions that we had here in the midseason time.

“For him to keep our team together and keep us focused, you have no idea what a task that is to keep a team together and not splinter.”

Fouts called the Incognito-Martin case “old-school meeting P.C.,” as in politically correct. He said he knows why the scandal did not “break’’ the Dolphins.

“Players are part of a team, and you always hear the terms ‘family’ and ‘unity’ on teams,” he said. “Either you’ve got it or you don’t, and I think the Dolphins have that.”