The upper critical field of clean MgB2 is investigated using the two-band layered Ginzburg-Landau (GL) theory.The calculated results are fitted to the experimental data of clean MgB2 crystal very well in a broad temperature range.Based on the GL theory for clean superconductors,a phenomenOlogical theory for dirty superconductor is proposed.Selecting appropriate parameters,two-band layered GL theory is successfully applied to the crystal of Mg(B1-xCx)2 and the neutron irradiation samples of MgB2.