Raspberry Pi Pico
Built-In RTC

The Pico has a built-in RTC that seems to keep time pretty nicely. Since there is no battery backup, the Pico needs to be continuously powered for the RTC to keep giving the correct time. That might lead you to resort to a separate RTC breakout for some projects. You don't always have to do that though.

The following program displays the time. I have commented the line that sets the time. Until you unplug the Pico, you don't need to repeat this line every time you change your program.

from time import sleep
from machine import RTC

rtc = RTC()
# (year, month, day, weekday, hours, minutes, seconds, subseconds)
# uncomment and set to the time every time you Pico has not been powered
#rtc.datetime((2022, 4, 6, 3, 8, 15, 0, 0))


while True:
    t = rtc.datetime()
    h = t[4]
    m = t[5]
    s = t[6]
    tstr = print(f'{h:02d}', f'{m:02d}', f'{s:02d}', sep=":")
    sleep(1)