A detailed study of the absorbing molecular clouds towards the radio source PKS1413+135, at a redshift z=0.247, is reported. Physical conditions are derived for the molecular gas in the frame work of two models: a homogeneous multicomponent model with equal filling factors, and a two-phase medium consisting of dense clumps embedded in a more diffuse component. Our absorption data are consistent with the presence of a diffuse gas component, dominating the observed opacity, and a dense component, accounting for most of the mass. We show that without knowledge of the small scale structure of the absorbing molecular gas, we can only derive lower limits to the column density. We find that the opacity ratio between two absorbing components in CO has varied by a factor 2.3 \pm 0.3. We also discuss what can be derived from molecular absorption line observations concerning the invariance of physical constants.