A relationship is found between the seismic moment, M_o, 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 M_o and the local Richter magnitude M_L, we obtain a relationship between M_L and t, of the form: M_L = a_0 + a_1 log t + a_2t^(1/3) + f(t), where a_0, a_1, a_2 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 M_L = a_0 + a_1 log τ + a_2(log τ)^2 + a_3Δ, 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 M_C that is compared to M_L 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 (M_L = C_0 + C_1M_C) 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 M_L and M_c. M_c 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