The last time Carlos Beltran tried bunting for a hit, Mariano Rivera, Derek Jeter and Andy Pettitte were still teammates.

On that same day — August 5, 2013 — Major League Baseball suspended Alex Rodriguez for 211 games. It’s not far enough in the past to have forgotten Rodriguez appealed the punishment, played the rest of the season and served a reduced suspension of 162 games in 2014.

But it has been a while.

Beltran was still suiting up for the St. Louis Cardinals, and he bunted for a hit but failed to reach safely against the Los Angeles Dodgers. He last beat out a bunt for a hit on July 7 that same year.

So it was a bit of a throwback to see Beltran, no longer the speedster who once stole 42 bases in a season, lay down a bunt in the Yankees’ 5-0 win over Baltimore Wednesday night, though he didn’t exactly need to rely on his legs.

The Yankees were up 2-0 when Jacoby Ellsbury led off the sixth inning with a single. With righthander Yovani Gallardo on the mound, the switch-hitting Beltran, 39, stepped into the lefthanded batter’s box. The Orioles’ infield shifted for him to pull the ball, leaving just shortstop J.J. Hardy on the left side of second.

advertisement | advertise on newsday

“Basically today was one of those days where I felt a little bit slow,” Beltran said. “I felt like I was battling my first couple of at-bats. I didn’t feel great at the plate, so I told myself from the beginning if Ells gets on base I’m going to try to drop a bunt.”

Players rarely bunt to beat the shift, but Beltran executed it perfectly, tapping the ball down the line and past third base. Hardy did not have a play.

“It’s really a smart play by Carlos,” Joe Girardi said.

That helped the Yankees load the bases with no outs and score their third run on Mark Teixeira’s walk.

It also was a reminder there are more ways to beat the shift, though Beltran did so in a more conventional manner in the eighth. He turned on a fastball and drilled it deep into the second deck in rightfield for his 20th home run of the season.

Yankees videos

“I got a good pitch to hit,” Beltran said. “It was a fastball, middle of the plate and up in the strike zone, so I was able to put a good swing on that.”

Beltran, who is hitting .304 with an .898 OPS, tied Alfonso Soriano for 52nd all time with the home run, his 412th. He also became the third Yankee to hit 20 homers at 39 or older, joining Alex Rodriguez (33 home runs at 39) and Babe Ruth (22 home runs at 39).

So don’t expect him to make a habit of bunting every time the defense shifts.

“I know that there’s going to be times,” Beltran said, “where I might be in the same situation and probably Joe will want me to swing the bat.”