For the commensurate (square-root 3 x square-root 3) R 30-degrees phase of p-H2 and o-D2 on graphite, we have calculated the phonon and roton band structures by the time-dependent Hartree method. A basis of three-dimensional harmonic-oscillator functions (up to n = 8 inclusive) is used for the translational vibrations and a basis of spherical harmonics for the weakly hindered rotations. The anisotropic potential between the molecules in the absorbed layer is taken from ab initio calculations. An anisotropic molecule-substrate potential is modeled semiempirically. Both potentials are explicitly expanded with respect to the molecular displacements, with the inclusion of high anharmonic terms, and with respect to their anisotropy. Moreover, the molecule-substrate potential is Fourier expanded to expose the effects of the surface corrugation. The structure of the in-plane phonon band agrees well with the data available from inelastic neutron scattering. For the peak that has been ascribed previously to the out-of-plane phonon band, we suggest an alternative assignment. For the rotons we have derived, both numerically and analytically, the dependence of the band structure on the (unknown) anisotropy of the molecule-substrate potential.