A relationship is found between the seismic moment, Mo, of shallow local earthquakes, coda amplitudes, and the total duration of the signal, t, in seconds, measured from the earthquake origin time. Following Aki, we assume that the end of the coda is composed of backscattering surface waves due to lateral heterogeneity in the shallow crust. Using the linear relationship between the logarithm of Mo and the local Richter magnitude ML, we obtain a relationship between ML and t, of the form: ML = a0 + a1 log t + a2t1/3 + f(t), where a0, a1, a2 are constants depending on an attenuation parameter (effective Q) and geometric spreading; and f(t) is a function of the instrument response and a (weak) function of the scattering process. This relationship is different from the empirical one generally used ML = a0 + a1 log τ + a2(log τ)2 + a3Δ, where τ is the duration measured from the first P arrival time and Δ is epicentral distance in kilometers. In the theoretical relationship, the dependence on epicentral distance is implicit in t. The theoretical relationship is used to calculate a coda magnitude MC that is compared to ML for southern California earthquakes which occurred during the period from 1972 to 1975. This comparison is made independently at six stations of the CIT network. At all stations, a good linear fit (ML = C0 + C1MC) is obtained. The standard errors range from 0.2 to 0.3 and the correlation coefficients from 0.80 to 0.90. Once station gain is accounted for, station correction terms are less than 0.17 magnitude unit when comparing ML and Mc. Mc calculation is not limited to a duration measurement but can utilize the entire earthquake coda in order to increase by many times the statistical confidence in an estimate of an earthquake's magnitude.