General advice in the construction industry is to replace hard hats at 3 to 5 years, on the basis that they will have suffered enough accidental knocks / drops and degradation from UV light to be less effective than when new. There may well be an element of manufacturer's pressure in there, but it sounds fairly reasonable to me and I've always stuck to it for cycle helmets.
Incidentally, hard hats are stamped with a date of manufacture.