Bitcoin Wiki clears it up:
That's not quite right either. The median of the timestamps from all your peers is used to adjust your local time. Here's the code:
int64_t GetAdjustedTime()
{
return GetTime() + GetTimeOffset();
}
As for the median timestamp of previous 11 blocks, isn't it the timestamp of the 6th from the last 11 blocks?
Not necessarily, because block timestamps do not need to be in order and can vary within the limits I gave above. The 6th last block might have a timestamp later than the 5th last block, meaning the 5th last block would be the median (if all the other block timestamps were in order).