When I had my medical done I asked about this, and was told by my AME that it was 5 years from medical issue - so even if it was the day before my 30th it would be valid for five years. Bit worrying that he got it wrong, because i could easily have been flying without a valid medical for seven months