There is a strongly increasing diffusion of Electric Vehicles (EV) and Plug-in Hybrid Electric Vehicles (PHEV), in order to reduce air pollution in urban environment and to mitigate the global warming issues. Anyway, the achievement of this latter goal strictly depends on the source of primary energy used to generate electrical energy. In the paper, a model for the optimal design and operation of a charging station for EV and PHEV assisted by a PhotoVoltaic (PV) plant is presented. A provisional model for the estimation of the incoming insolation, based on cloudiness prevision, is integrated with a nonlinear constrained optimization algorithm, in order to satisfy the load while minimizing the recourse to electrical grid for battery storage charging. Simulations on different locations and charging loads for various size of PV plant and battery capacity are presented, and the benefits in terms of CO2 reduction discussed.