There are several considerations for lighting a 3-5 gallon aquarium. (If you don’t have live plants, though, you can ignore this section and do whatever you like.)
I run my tank light plugged into a digital timer. For the sake of my plants, it’s on from 9 in the morning to 10 at night, since my light is relatively weak. (Most very small aquariums come with weak lighting, for reasons too complicated to go into). I never have to touch it to turn it on or off, and the timer even “remembers” what time it is and my instructions after it’s been unplugged for a water change.