1. We know from the time circuit displays that Marty arrived in 1955 at 6:00 AM on November 5, and that the climax of the movie was that he and Doc would have to channel the lightning from the clocktower, which would strike at exactly 10:04 PM on the 12th, into the DeLorean. So Marty spent 7 days, 16 hours and 4 minutes in 1955 that first time.
2. Doc took Marty and Jennifer to October 21, 2015, 4:29 PM, and near as I can figure from various sources such as the film and the Futurepedia (every damn thing has a wiki now) they left at 7:28 PM, so they spent about three hours in the future.
3. Technically I suppose I shouldn't count this, since 1985A aka "Hell Valley" is the present, but it's such a radically altered version of the present that I'm counting it as a separate time period. Marty, Doc and the unconscious Jennifer arrived at 9:00 PM and then Doc and Marty left at 2:42 AM, so they spent about 5 hours and 42 minutes there, two of which Marty spent unconscious thanks to Hell Biff's cronies.
4. They arrived back in 1955 on the date of November 12, 1955, 6:00 AM, so Marty ends up living that particular day twice. After being stranded there, he gets the letter from Doc in 1885, tries to get help from '55 Doc and so on and so forth. Examining the events of BTTF3, most agree that Marty left 1955 for the final time on November 16, 1955, 10:00 AM, so he spent 4 days and 4 hours there this second time around.
5. Once in 1885, the DeLorean was damaged, requiring a rather complicated series of events to get the DeLorean back to 1985. Marty arrived on September 2, 1885, 8:00 AM but the departure date is a little iffy. The Futurepedia says that Marty left at 9:00 AM and yes, Buford did arrive for the duel early but the fight with Marty and Doc did go past 8:00 by at least a few minutes and then Doc and Marty had to catch up to the train, commandeer it, detach the cars, go to the spur, ready the DeLorean, and all the rest of the events of pushing the car up to 88 mph. In this case, without a good look at the Present Time display, I've chosen to believe it was more about 9:30 that Marty departed, meaning he spent 5 days, 1 hour and 30 minutes in the Old West.
So how long did that weekend end up being for Marty? Between the time we see him in the first movie on Friday morning, October 25, 1985 to Sunday, October 27, Marty spent 17 days, 6 hours and 16 minutes in various time periods and alternate timelines.
The longest time he stayed in was 1955 at 11 days, 20 hours and 4 minutes. The shortest time he stayed in was 2015 at just 3 hours. Great Scott!