Anthony Rizzo of the Yankees celebrates after his fourth-inning home run...

Anthony Rizzo of the Yankees celebrates after his fourth-inning home run against the Kansas City Royals at Yankee Stadium on Sunday. Credit: Getty Images/Al Bello

If time travelers from March visit Yankee Stadium on Tuesday night, they figure to be shocked by what they encounter.

Not one but both alleged World Series contenders from New York out of playoff position in late July?

The Yankees tied with the Red Sox for last place? The Mets 18 1⁄2 games out of first place?!

The good news for the Yankees and their fans as they host the seemingly hopeless Mets for two games is that all is not lost.

That vibe was evident before, during and after Sunday’s 8-5 victory over the Royals, which completed a three-game sweep, improved the Yankees to 53-47 in their first 100 games and kept them within two games of a wild-card spot.

Before the game, Jonathan Loaisiga pitched to Aaron Judge in a live batting practice session that indicated both might be nearing a return to action.

Judge did not put a ball in play in 16 pitches — he fouled off four and swung at and missed one — but manager Aaron Boone said he was pleased with what he saw from him, and from Loaisiga.

“Seeing him out there throwing the ball like that is really encouraging,” Boone said of his reliever, who has been sidelined since April 5 by an elbow injury.

Also on Sunday, Nestor Cortes allowed a run and four hits in 2  1⁄3 innings in a rehab stint at Double-A Somerset as he comes back from a shoulder injury.

During the game, Anthony Rizzo went 4-for-4 with a double and his first home run since May 20, breaking out of a long slump.

After the game, Boone had this to say: “Look, we’ve got a long way to go. We feel like we have a chance to be a really good team.

“We’re incomplete, without question. But we do feel like there are some things on the horizon that are going to fortify us. We’re excited to get those parts back.”

This was four days after Boone said, “We stink right now” in the wake of a 1-5 road trip and a 2-9 stretch overall.

The Royals (28-73) can have that sort of effect on a team.

Now the degree of difficulty will go up, one step up to the Mets, then another big one with six games in a row against the AL East’s top two teams, the Orioles and Rays.

“Long way to go,” Boone said on Sunday. “It’s definitely good to kind of right the ship here with a good weekend. But the good thing is we’ve got a lot of baseball in front of us and we’re in control of our destiny.

“We’re in control of the story. We get to write our own story. It’s all right there in front of us. We’ll enjoy that off day [Monday] and be ready to try and come out and shake hands on Tuesday.”

The Mets and Yankees split two games in Queens in mid-June.

Subway Series games are standard stuff for players these days, but when pressed, they did acknowledge that games against the Mets have a little extra juice — at least in the stands.

“With the Mets coming, it’s going to be exciting,” Rizzo said. “The fans will be into it. They’re a team that wants more and so are we, so it should be a fun, good two games.”

American League Cy Young Award winner Justin Verlander is due to start for the Mets on Tuesday. Verlander faced the Yankees in Game 1 of last season’s ALCS and allowed one run and three hits in six innings, striking out 11 and walking one. The Astros won, 4-2, and went on to sweep the series.

“It doesn’t matter who they’ve got going,” Giancarlo Stanton said. “We’ve got a job to do. We’ve got to trust ourselves and doing what we can do and get two wins out of that.”

SUBSCRIBE

Unlimited Digital AccessOnly 25¢for 5 months

ACT NOWSALE ENDS SOON | CANCEL ANYTIME