We assessed the accuracy of the four members of the M06 family of functionals (M06- L, M06, M06-2X, and M06-HF) for the prediction of electronic excitation energies of main-group compounds by time-dependent density functional theory. This is accomplished by comparing the predictions both to high-level theoretical benchmark calculations and some experimental data for gas-phase excitation energies of small molecules and to experimental data for midsize and large chromogens in liquid-phase solutions. The latter comparisons are carried out using implicit solvation models to include the electrostatic effects of solvation. We find that M06-L is one of the most accurate local functionals for evaluating electronic excitation energies, that M06-2X outperforms BHHLYP, and that M06-HF outperforms HF, although in each case, the compared functionals have the same or a similar amount of Hartree-Fock exchange. For the majority of investigated excited states, M06 emerges as the most accurate functional among the four tested, and it provides an accuracy similar to the best of the other global hybrids such as B3LYP, B98, and PBE0. For 190 valence excited states, 20 Rydberg states, and 16 charge transfer states, we try to provide an overall assessment by comparing the quality of the predictions to those of time-dependent Hartree-Fock theory and nine other density functionals. For the valence excited states, M06 yields a mean absolute deviation (MAD) of 0.23 eV, whereas B3LYP, B98, and PBE0 have MADs in the range 0.19-0.22 eV. Of the functionals tested, M05-2X, M06-2X, and BMK are found to perform best for Rydberg states, and M06-HF performs best for charge transfer states, but no single functional performs satisfactorily for all three kinds of excitation. The performance of functionals with no Hartree-Fock exchange is of great practical interest because of their high computational efficiency, and we find that M06-L predicts more accurate excitation energies than other such functionals.