Well first off the clock stops for a rider in the peloton when the peloton of riders crosses that stages' finish line, so even though one rider might be at the front of the peloton and another might be at the back, they get the same time.
You may have noticed riders (like sprinters and domestiques) getting dropped by the peloton in the mountain stages, they loose overall time because they finish behind the peloton.