Energy conversion from the environment into electricity is the most direct and effective electricity source to sustainably power off-grid electronics, once the electricity requirement exceeds the capability of traditional centralized power supply systems. Normally photovoltaic cells have enabled distributed power generation during the day, but do not work at night. Thus, efficient electricity generation technologies for a sustainable all-day power supply with no necessity for energy storage remain a challenge. Herein, an innovative all-day power generation strategy is reported, which self-adaptively integrates the diurnal photothermal and nocturnal radiative cooling processes into the thermoelectric generator (TEG) via the spectrally dynamic modulated coating, to continuously harvest the energy from the hot sun and the cold universe for power generation. Synergistic with the optimized latent heat phase change material, the electricity generation performance of the TEG is dramatically enhanced, with a maximum power density exceeding 1000mWm-2 during the daytime and up to 25mWm-2 during the nighttime, corresponding to an improvement of 123.1% and 249.1%, compared with the conventional strategy. This work maximizes the utilization of ambient energy resources to provide an environmentally friendly and uninterrupted power generation strategy. This opens up new possibilities for sustained power generation both daytime and nighttime.