Metasurfaces are ultra-thin, two dimensional versions of metamaterials. In this talk, I will cover the possibilities offered by electromagnetic metasurfaces for performing elaborate functions which up to now have been realized with bulky, three-dimensional structures such as lenses, gratings, optical cavities and delay lines. Such advanced functionalities are made possible by spatially or spectrally controlling the phase discontinuity imposed by the metasurface on the impinging wave. In the first part of the talk I will focus on metasurfaces for reconfigurable wavefront manipulation. I will show two examples: all-dielectric metasurfaces made of dielectric particles supporting toroidal- and magnetic-dipole Mie resonances [1], and metallic patch metasurfaces with integrated tunable elements offering complete local control over the complex surface impedance [2]. In the second part, I will discuss multi-resonant metasurfaces for dispersion engineering with an emphasis on tunable broadband time delay [3]. The proposed metasurfaces are of deeply subwavelength thickness, thus exhibiting significant technological advantages over conventional diffractive and dispersive optical elements, respectively.