? It was back to the future at the box office this weekend as a new adaptation of the science fiction classic “The Time Machine” opened in first place, according to studio estimates Sunday.

The movie, based on the 1895 book by science fiction master H.G. Wells and directed by Wells’ great-grandson Simon Wells, took in an estimated $22.5 million from Friday through Sunday.

In second place was “We Were Soldiers” in its second weekend, and opening in third was “All About the Benjamins,” an action comedy starring Ice Cube.

“Time Machine” was previously made into a movie in 1960, under the direction of George Pal. The new version stars Guy Pearce as a scientist from a century ago who builds a time machine seeking to undo a tragedy from his past.

He’s ultimately hurtled 800,000 years into the future, where the remnants of humanity have split into two species: Benign surface dwellers and a savage underground race.

“We Were Soldiers,” Mel Gibson’s Vietnam War saga, held up well from its opening last weekend, dropping only 29 percent to take in an estimated $14.5 million.

“All About the Benjamins” opened in only 1,505 theaters, compared with 2,944 for “Time Machine,” and took in $10.1 million. The film’s per-screen average of $6,728 was not far behind the $7,643 average for “Time Machine.”

“All About the Benjamins” stars Ice Cube as a bounty hunter pursuing a bail-jumping con man (Mike Epps). During the chase, the two wind up in the middle of a diamond heist. The movie was co-written by Ice Cube, who also was one of the producers.

Estimated ticket sales for Friday through Sunday at North American theaters, according to Exhibitor Relations Co. Inc.:

1. “The Time Machine,” $22.5 million.

2. “We Were Soldiers,” $14.5 million.

3. “All About the Benjamins,” $10.1 million.

4. “40 Days and 40 Nights,” $7.1 million.

5. “John Q,” $6 million.

6. “Return to Never Land,” $4.7 million.

7. “Dragonfly,” $4.1 million.

8. “A Beautiful Mind,” $3.9 million.

9. “Big Fat Liar,” $3.4 million.

10. “The Lord of the Rings: The Fellowship of the Ring,” $2.6 million.