The coupling between electrons and external field is described by means of Modern Theory of Polarization. Correlation effects are derived from Green's function theory. We show that the inclusion of local-field effects and electron-hole interaction is crucial to predict and reproduce second and third harmonic generation in low dimensional structures, where strong bound excitons are present. Finally in the last part we introduce a real-time density functional approach suitable for infinite periodic crystals in which we work within the so-called length gauge and calculate the polarisation as a dynamical Berry's phase. This approach, in addition to the electron density considers also the macroscopic polarisation as a main variable to correctly treat periodic crystals in presence of electric fields within a density functional framework.